Comprehensive Software Architecture

I have a few questions about the software architecture I'm working on!

Thus, this software allows the user to access some popular sites:

  • Social networks (Facebook, MySpace, ...),
  • Shared Services (RSS, Mail, Twitter ...),
  • Social Bookmarking (Digg, Delicious ...),
  • Chats (MSN, AOL ...),
  • ...

Currently, the architecture is as follows: Using MVC and Observer / Observable design patterns for interaction between the model (TApp_Core) and the user interface.

TApp_Core TBookmarkingServices_Core TDelicious (implement IBookmarkingServices) TDigg (implement IBookmarkingServices) etc... (implement IBookmarkingServices) TChatServices_Core TMSN (implement IChatServices) TGoogleChat (implement IChatServices) TAOLChat (implement IChatServices) etc... TRSSServices_Core ... 

Thus, the software creates an instance of TApp_Core, and then, depending on the user's choice, it creates some instances of other services (for example: App_Core.BookmarkingServices_Core.AddServices (Digg, User, Password);).

Some questions!

  • Do you think the current software design is right?
  • Currently, there is only one thread for all software ... Would it be better to create a new thread for each service request? (for example, TDigg receives a message from a button, it creates a stream that will create TidHTTP, generate a request to the server, wait for a response, analyze the response, send a message to each observer (callback), and then a free stream.
  • It seems very difficult to connect all View / Controller with each part of the model, is it normal that it takes so much work? For example: to send a message, for example, using Twitter, this will require:
    • Attach the controller (button) to the TApp_Core.TMicrobloggingServices_Core.TTwiter object (model).
    • wait for user to click
    • Send a message to TTwiter (model)
    • Create a thread to send a request to the server
    • Analysis of the response from the server
    • Make callbacks to notify that the request is complete and give a result
    • Free flow
  • If I use the previous idea, will it not create too many threads and make the computer slower and less responsible? Also, if I implement a thread pool (but it is rather difficult to use it).
  • Is SQLite 3 good enough to store all the data on the client? (data can be mail, rss channel, etc.), so time can be quite a lot of data.)

Thank you and sorry for my bad english!

+2
source share
3 answers

Do you think the current software design is right?

Perhaps there is no objectively β€œcorrect” design - there are only the best or worst projects. :) It seems that you are on the right track, but I would advise you to leave your GUI and view the decoupled ones from internal services. For instance:

  View --- Controller --- Service 

This way, View knows how to display things (i.e. IM messages, web content, or something else) and passes requests from the user to the Controller . Controller receives notifications from Service and updates the View . Service does not know anything about the interface (therefore, it can be accessible for scripts, which is very useful) and simply implements the protocol necessary for communicating with a network service. You will have a separate set of these three classes for each separate server system and a common controller for managing the application on a global level.

It seems very difficult to associate all View / Controller with each part of the model, is it normal that it takes so much work?

Perhaps yes, you are trying to use a non-trivial application. I assume you are using MVC style architecture. It may take more effort to get things right, but it's definitely worth it. The more complex your application, the more you will benefit from bundle and decoupling.

Would it be better to create a new thread for each service request?

Given that all services are network-based, you need to block blocking I / O calls (such as reading sockets) from blocking the main GUI thread. Thus, you need to either fully use asynchronous I / O with callbacks in one thread (not very often), or have a separate thread for each network session (the most common approach). I would not recommend creating a new thread for each individual request, but for the entire session. You need to be careful to avoid common threading issues such as race conditions and dead ends (this topic can fill the book). The thread will have to send a message back to the GUI for notifications, since you cannot update your GUI from the context of another thread.

(for example, TDigg receives a message from a button, creates a stream that will create TidHTTP, generates a request to the server, waits for a response, analyzes the response, sends a message to each observer (callback), and then release the stream.

It looks like you have a GUI associated with your controller and protocol handler. I suggest you separate the interface and the end, and keep things untied.

If I use the previous idea, will it not create too many threads and make the computer slower and less responsible?

Themes are commonly used to make a computer more responsive. Creating threads has some overhead and requires great care for proper synchronization. But if you have one thread per network session, overhead will not slow down, since you will only have the most.

Is SQLite 3 great for storing all the data on the client? (data can be mail, rss channel, etc.), so the time can be quite large.)

SQLite is a great database for this purpose. It is used by some of the largest software houses in the world for client-side storage management. It is very fast and efficient, and I am sure that it can keep up with your application.

You seem to be involved in a complex application. I suggest you buy a book on concurrent programming and read a little more about streaming usage. This is a very complex problem and can lead to errors that are incredibly difficult to track if not programmed with great care. Good luck

+4
source

I would recommend using an ORM structure to abstract from your database. This gives you a meaningful level of data abstraction, and also means you don't have to worry about choosing a database. SQLite is a good compact database. This may be ok for testing. But he, of course, is not going to reduce it in a real multi-user environment (he has a file-level lock, which, of course, will make simultaneous CRUD impossible on any significant scale). It also uses only a subset of SQL. Use both ORM and you can easily change later.

0
source

Looking at your post, it's hard to decide if your architecture is good or not. That's what I aim for

  • It works?
  • Make a minimum for it to work.
  • Clean your design when you go.
  • Use tools to visualize design.

I found it extremely useful to use tools like NDepend to visualize the dependency.

-one
source

All Articles