web developer & system programmer

coder . cl

ramblings and thoughts on programming...


my software design principles

published: 05-05-2012 / updated: 06-05-2012
posted in: development, haskell, java, programming, projects, tips
by Daniel Molina Wegener

Most modern applications are providing APIs. That allows you to integrate those applications providing APIs with third party applications and create a real cloud computing environment. From an architectural perspective, we should have at least to have in mind the architectural pattern to be used, design patterns to be implemented, the protocol to use and the data format to expose the API. The architectural pattern should be simple, the design pattern efficient, the protocol lightweight and the data format flexible for your requirements. With a good API design, it should be stable enough to support changes along the time dynamically.

The architectural pattern should be simple. Most people is thinking on the MVC architectural pattern as the most proper architectural for any application. But really the MVC pattern was designed with very old basis and mostly with the idea of generalizing the user interface of desktop applications. Currently, Web Applications are build on top of many technologies, not RDBMS engines only, so you should start using the proper architectural pattern, where technology diversity should follow the maximum cohesion principle, rather than coupling application components.

We have as key principle of design «minimum coupling, maximum cohesion», but I would like to add «proper generalization». So, finally we should have «minimum coupling, maximum cohesion & proper generalization» as design basis. If we observe, generalizations are older than software, we can stage that the term comes from Maths, where a generalization is a concept that can be applied to multiple problems and solve them using that concept. Cohesion is the principle of independent components that can work together, and coupling is a design which cannot separate its components. One of the best and classical examples of maximum cohesion on its design is Unix, where there are many small tools that can work together without coupling its functionalities.

A good generalization comes with from a good model, and any good generalization usually is able to solve multiple problems at once. Object Oriented programming provides a rich interface for abstractions, where the generalization is one of the most powerful ones, but in words of real generalization, I can proudly say that Monads are one of the best abstractions and mostly generalization that I ever seen.

  • Haskell Programmer: Hey Java programmer, you know how just about everything is represented by a class?
  • Java Programmer: Yea…
  • HP: Even stuff no business being a class
  • JP: Well, it is our fundamental abstraction for anything larger than a function. It may be clumsy, but it can be used to implement any other design pattern we need.
  • HP: Well Monads serve the same role for us.
  • JP: Nulls?
  • HP: Maybe Monad
  • JP: I/O?
  • HP: IO Monad
  • JP: Exceptions and error handling?
  • HP: We have several ways, but mostly Maybe Monad
  • JP: List comprehension?
  • HP: Again, Monads
  • JP: Mutable data structures?
  • HP: That would be the State Monad[2]

With the proper generalization you can make your design to be consistent, robust and reliable. But you must leave the generalization concept just as hierarchy problem. It should be stated globally as computational problem rather than design problem only. A generalization as computation can be applied to multiple problems, where applying computational generalizations we can find mapping functions that can be globally used. This can be reached combining the IPO model and Object Oriented models properly, working together.

Software design is not easy. An UML class model is not enough, where it can only display structures, probably with a sequence models and communication models you can reach a good IPO design, but not without the proper knowledge about the implementation. So, any analyst who does not knows how to program, is just wasting your money and time, with the obvious further reimplementation and redesign of the software product.

And you should start adding the proper generalizations as computations to your design, working together with your hierarchical generalizations, so they can bring you the proper quality along the time.

[2] This is an excerpt from a discussion on a programming forum.


No coments yet.

post a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>