So, I've recently been putting in some really really awesome improvements to BarelyMVC. So much so, that I'm beginning to think it should be renamed because it's not longer "barely" an MVC framework. It still goes by the principal of minimalism, but my second principal now though is as little magic as possible. And also as few "magic strings" as possible in a web framework.
Magic strings I think are quite horrible. Magic strings can take a few different forms. All of them are equally evil in my opinion. Examples:
Dictionary<string, object> instead of a strictly typed class
- Specifying method or property names of a strictly typed class as a string for the purposes of reflection and it "magically" working
- other strings which semantically mean something and can't be changed at whim (ie routing strings)
- Anonymous classes in some cases are really just magic strings in disguise. Particularly throughout ASP.Net MVC.
Now of course, not all magic strings are avoidable... and of course some magic strings are avoidable, but it'd be a super huge pain to do by static typing. This should be the exception, not the rule.
So, instead of using anonymous methods and magic strings that point to methods, in BarelyMVC I make everything very explicit and statically typed. The only thing close to magic strings are:
- Route URLs... I actually have a plan to eradicate that problem even
- Mappings of HTTP POST and route parameters to static classes. It isn't really possible to do this without sorta magic strings.. at least not and your code be easy to read
So, instead of relying on reflection that no one can intuitively figure out, and referencing filenames and methods as strings to keep code as small and "concise" as possible, I make you type a bit more. But, in exchange for typing a bit more, it's blisteringly easy to figure out why things work like they do... and when you decide to refactor and change your method names in your controller to something else, you're not left wondering why it no longer works because if you do that with BarelyMVC, it will give you a good ol' fashion compiler error.
Also, have I mentioned statically compiled and typed views. VIEWS.
Of course, BarelyMVC is definitely still going through a huge metamorphosis to become something really cool to use. It's API is breaking each day right now, but these changes are beginning to get wrapped up(I don't even have this website using the latest version anymore).. However, when it finally hits 1.0, you're going to wonder why someone didn't make such a thing earlier!