6

Engineering is typically the art of knowing what solution fits best to the problem. If I were asked such as Should I use singleton classes?, Should all database have views and triggers?, What is the greatest PHP framework?, Is C++ or Go better?, or Is RSA or AES more secure? I will most certainly answer "It depeneds..."

But one question stands out, "Should I use modular design?" - "Absolutely"

I have not once doubted modular design in my experience. Software that I make must be assembled, put together, and interchangeable like Lego bricks (after you define what a brick is of course). No matter what language, no matter what machine, no matter what purpose, ect. So I have yet to say "it depends" when ask if modular design should be used.

Nearly every other aspect of software engineering has a take-give index it can be put on. Modular design (so far) only ever gives and gives. This frightens me and I constantly seek out why anyone would not use modular design. I mean if you program in such a way where all the code is glued together and contains variable length functionally and limited expandability, and no means of error severability, does that automatically mean you're a bad programmer? Is there any reason to code in that fashion besides laziness? Are their any other ways to design a project in? Or is modular designing the above all most 100% undisputed right way of doing things (just like breathing)?

  • @gnat That is actually a very good Q&A I did not see. But my question still stands as it asks it in a more head on way. – Sanchke Dellowar Dec 22 '16 at 21:45
  • You'll have to define what "modular" means. For some answerers on this site, "modular" doesn't contain anything less than fully SOLID super loosely coupled everything, – whatsisname Dec 23 '16 at 3:40
  • 1
    Software always has a modular design. If you've written more than a single main method, you've already created a modular design. So the question is not whether your software should be modular or not. – Robert Harvey Dec 23 '16 at 15:43
  • @RobertHarvey Well that does not mean it's modular on a higher level. Such as plugins, addons, mods, and core components. You can have multiple functions, and multiple files, but that does not mean its modular... it could just mean you have one module spread out through multiple functions and files. – Sanchke Dellowar Dec 23 '16 at 15:47
2

Modular design requires (a non insignificant cognitive) effort as a design heuristic, but its benefits come back in

  • managing complexity,
  • simplifying long-term maintenance,
  • facilitating reuse,
  • etc.

So, a project that doesn't care about any of those things would be one where modular design would be a waste. It's similar to Thomas Kilian's answer mentioning very small systems.

For an analogy, think about IKEA furniture and all the modular design effort that go into it. Then, ask yourself if you just needed a table to put food out for guests for a one-night celebration, you'd hack something out of whatever you had at your disposal to solve the problem (kids do this quite well!). Designing a new IKEA-like table (with modular parts) for this purpose would be overkill for your one-night party.

I like Neal Ford's spectrum of design. Modular design (the way I see this) would not even exist at the "cowboy hacking" extreme.

http://www.slideshare.net/ThoughtWorks/neal-ford-emergent-design-and-evolutionary-architecture

8

What is NON modular design? For me it would be a monolithic design. Those have advantages in very small systems. This is where any kind of resource is limited. That might be memory, CPU or even the time a coder can spend to create it. A monolithic design can be grasped in one single piece (or more specifically it NEEDS to be). In that way you get the whole picture. But again, you NEED to get the whole picture. So as long as the system is small, this will be feasible. Starting from a certain size you definitely want modular design. Rule 1 to eat an elephant: eat it in slices.

  • Would an analogy be to hard to ask for? :) – Sanchke Dellowar Dec 23 '16 at 1:32
  • Analogy for what? A whale-tactic would be the same. – qwerty_so Dec 23 '16 at 9:38

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