Reputation: 1117
Is there a reference to design and implement a framework? What are the characteristics of a framework? And what features should be? What requisites must be covered? Are the ORM associated with the Framework?
thanks
Upvotes: 0
Views: 1537
Reputation: 1531
Your question is indeed a bit vague, but it's kinda interesting in terms of "coding philosophy". I don't claim my answer to be the only way to do such things, especially without any specifics about your problem. It's just a set of guidelines I'd personally use and hopefully they will be helpful to you.
So, first of all, you have to really understand what's the problem you are trying to solve. I will not consider "I do it for educational purposes" as an option here. Try asking yourself questions like these:
Do you need to solve a singular problem?
A simplistic example: if your application needs to sort an array or, to be a bit closer to your field, calculate mean or deviation - all of those are singular problems. Your really shouldn't include a complete set of all known sorting algorightms in your application just to sort an array, same way you don't really need a deep statistical analysis system just to calculate a mean. I'd consider developing library specific to your problem.
What's wrong with current solution?
Such generic notions as frameworks are usually born when current solution is present, but there is a way to interact with it more efficiently. It's a really bad idea to hide bad code or design under the hood of some kind of abstraction. If current solution works well but its implementation seems to be a problem, I'd start with refactoring existing code, not rewriting it from scratch or hiding it.
Is it a recurring problem?
One of the most valueable features of generic pieces is reusability. It is always much harder to build something generic, yet useful. Harder means expensive, so you have to justify wasting time on building generic blocks. If you don't or can't use your expensive blocks in more that one place, you probably don't need them and better off developing concrete solution instead.
The reason I marked out these questions is that I often see code which its developer calls a framework and puts considerable amount of time and effort into it, but he ends up doing something that is not a framework and most importantly, it shouldn't be one in the first place.
So, we got to first part of your question:
Is there a reference to design and implement a framework? What are the characteristics of a framework? And what features should be?
It'd be appropriate here to give you a list of design guides and features that are exclusive to frameworks, but I don't think that it's a good idea. Here's why: there is no ISO or any other official or widely used standard for software frameworks development. And that's because framework does not solve particular problem, it provides means to do so - which is its most important feature.
A very common misconception about frameworks is that they must be absolutely transparent and should be able to bend to any need. Framework developers and users must understand that framework is hardwired to some point. And that's not because you can't do it otherwise. You can, it's called metaprogramming. The reason is that framework implies an invariable internal behaviour, which is usually called a "core of framework". It'd probably be useful for a client to have a way to extend this behaviour, but not modify it.
Point is, framework must dictate how client interacts with an environment. In a bit more strict terms, when client operates inside the framework, control flow is kind of reversed: framework evaluates client's code and makes appropriate calls, it is now framework who calls client, not the other way round, like it is with plain libraries. Ofcourse, there might be some exceptions, but I'm talking about general idea here.
Then you ask:
What requisites must be covered?
As you probably figured already, there are no strict requisites. But there are few things that I'd like to suggest:
And the last part of your question was:
Are the ORM associated with the Framework?
Well, yes and no. If your framework depends on data storage which is not specific for every instance, you should have some kind of abstraction for that. And ORM is probably the best way to go in this case, but there are few things I'd like to point out:
Okay, that's it for your questions, but I'd like to add some tips if you ever decide to develop a proper framework:
Upvotes: 2