Search This Blog

Wednesday, March 9, 2016

Work on your framework before starting, or maybe not

Odd title, right? I will try to explain, ideally you should plan your framework and code structure before starting to invest loads of time on more details code, however many times it is difficult to come up with a good code structure / framework till you really know what you want to have and how you want to do it.

You have therefore a couple of choices:

  1. Use some pre-made structure / framework which will impose the way to work. This is good if you have not overall a very good background, or if you want to work with something let's say "standard" which would allow 3rd party to participate quickly in your project development.
  2. Plan carefully your framework and spend quite some time design it before starting actually to code the details. You may develop a couple of "modules" to see if your framework make sense but don't go too far into the real development till you have the framework set.
  3. Start to develop all around, and be prepared to develop your framework once you know what you want to have and know how it should work. However be prepared to re-design your "modules" to fit your new vision of the framework. This last route may require multiple re-designs but may offer the best solution if you agree to rewrite / refactor your code.
In any case it's really important that you document your framework / design once you decided how it will be. That will allow other people to jump on the boat and will clarify your mind as well. A good designed framework can be reused on multiple projects therefore time invested on it is never actually really lost.

For the framework / design, for me even the directory structure of your project is important. Why? Because as the project grows, the number of files should grow as well (not just a couple of big files, but better many smaller one). So if your directory structure is not good you will lose a lot of time searching things around.

Personally I like to split features as "modules" and have all the files related to the feature in one directory. Like if I do web development I would have the template, back-end, typescript / javascript and css files related to a single feature all in a single directory. So if I need to work on that feature I will find all the related files in a single directory.

Other people like to split things differently like having the "back-end" in a directory, all the css in another, the templates in a 3rd and so on.

Which structure fit you best is your own personal design choice, and as in many cases there is no single "best" or "right" solution.

No comments:

Post a Comment