2

So after a while of working in programming field I still haven't figured it out how exactly should programs be structured, in a large set I mean. Which I think it's also because of working in an enterprise development.

Say that I want to write a program, a messenger for a LAN network. How do I really know what classes to make for this program? How to divide the program into smaller pieces and classes in the best and most efficient way? This is just an example. I don't mean specifically for this problem set, it's the general approach that I am wondering about.

EDIT: I have asked this question here because it exactly says in the help center:

What topics can I ask about here?

Programmers Stack Exchange is a Q&A site for professionals and students in software development and related fields who are interested in getting expert answers on conceptual questions about software development.

If you have a question about...

software requirements

software architecture and design

algorithm and data structure concepts

My question, according to my understanding, refers to the to the software architecture and design. It's not a specific coding question otherwise it would have been asked on Stackoverflow. It is a conceptual question which should be fit here. The comments and answers are referring to that there are a lot of books covering this topic. I'd accept even a book name for an answer if the book answers my question. If the answer does not fit into this form of Q&A, at least I could be pointed to the right direction. After all we're all here to learn something.

closed as too broad by Telastyn, Robert Harvey, Giorgio, Euphoric, Bart van Ingen Schenau Jul 6 '14 at 20:10

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    This is pretty much the definition of "too broad" to me. – Telastyn Jul 6 '14 at 17:43
  • "Your questions should be reasonably scoped..." (help center) meta.programmers.stackexchange.com/questions/6483/… – gnat Jul 6 '14 at 17:45
  • 1
    I cannot really see how would you make this question more specific. It's a valid question imho. I have not asked explain java to me (which I can see that it sounds so a bit) but what I really want to ask is how to break down a program into smaller pieces in the best way. I'd be glad to hear your comments and critics and help to ask in the right way if it's not. If it really does not fit the standards of this website, I remove it. – Erfan Jul 6 '14 at 18:18
  • 2
    There are many, large books written about how to structure programs. It's not a question we can answer well here. – Telastyn Jul 6 '14 at 19:13
  • 2
    @Erfan: The question is on topic here, but we can't really provide you with 200+ page answers. Much of your question fills entire textbooks on the topic of Object Oriented Analysis & Design. – Bart van Ingen Schenau Jul 6 '14 at 20:12
4

By some definitions, a class is a type (or a structure) that provides implementation and interface (assuming it's not an abstract class) for some specific sub-set of a problem.

With that in mind we can say that most sensible way of organizing and naming class would be to divide them logically.

In your given example the classes could be:

Message
Session
Atendee
Status
Connection
... and so on

This is all strictly related to OOP: Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming#Additional_features - if you take a look at the Encapsulation enforces modularity you could see that

Encapsulation refers to the creation of self-contained modules that bind processing functions to the data. These user-defined data types are called "classes," and one instance of a class is an "object." For example, in a payroll system, a class could be Manager, and Pat and Jan could be two instances (two objects) of the Manager class. Encapsulation ensures good code modularity, which keeps routines separate and less prone to conflict with each other.

... which is more or less what I was trying to convey.

Not the answer you're looking for? Browse other questions tagged or ask your own question.