Building a framework...

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Building a framework...

Post by alex.barylski »

In response to the thread on Java, where feyd and myself were disscussing MFC, OWL, etc...also in regards to my other thread about CMS...

Basically I want to start development of my own CMS...but as always, not being paid is allowing me full control over how it is built :P

I'm convinced a full fledged template engine and DB abstraction is not a big enough deal to exclude it from a CMS application - modularity/portability I always favour, unless speed is a issue.

However, now my concern is (this is where Feyd's and mine convey comes in as MFC doesnt' follow any standard, it's dog meat sometimes) coding standards and conventions...

Deep down, they are critically important to me...I have a style which i've used for years and although could use upgrading, I feel it very important to follow a consistent coding style throughout an application. Here's the problem. TL and AdoDB lite may very well follow a coding standard, but it's different from my own and the function names are not quite what I would label them as.

I can't be bothered to sift through the code and change conventions, etc, comments and what not...

So I'm stuck at this road block...should I continue development on my own framework until it's complete (which could take a while as I have other things to do) or do I somehow bite the bullet and work with what I've got...

Refactoring code later as my own framework comes togather is *not* an option...I couldn't be bothered to muck with an complete application like that...

Silly question, perhaps as only I can truely answer this...I'm anticipating starting this CMS, but at the same time don't want a hodge podge of code libraries all with different coding conventions, standards, etc...

Interested in hearing comments, opinions, etc.. :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Learning how to work in other people's code is part of being a developer, senior or not. So although I can understand the frustration in having to work with another's framework, it's probably a valuable experience, if only to give you more ideas of "things to correct" in your own framework later. Unless you can truthfully say your framework is/will-be different than the bulk of the others out there by a decent margin, I would seriously consider using someone elses existing and established framework.

If you can't be bothered to learn their codestyle, build a "beautifier" to convert the code to your style. Although I will raise an "arrogance" flag at it, but won't do much worse than that. :)

It may be a good time to embrace(?) a unit testing solution such as SimpleTest or PHPUnit if you do choose to roll-your-own. Since you are in the largely planning stages of this major overhaul, it may be good to look into TDD, Agile, etc. I've posted on this before -- read the multitude of threads in Theory of late for examples.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

My not very humble and slightly belligerent opinion is that until to main thing that bothers a programmer is bad design they are not there yet. The thing I admire about programmers like feyd is that, while they will occasionally mention this or that thing that annoys the about code, their main focus -- like a laser beam -- is on the the design of the code: what's good and what need to be improved.
(#10850)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Image
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Learning how to work in other people's code is part of being a developer, senior or not
Fare enough, but thats not the problem...as i've had my fare share of toiling with others code, fixing, documenting, etc...

It's just, I want everything to be as professional as possible and coding conventions are a step in the right direction...not that TL or AdoDB are not professionally written...I've peaked at the source and I like AKAPJ style and everything, it's just not my own...

This is where programming, for me anyways, becomes as much as art as it does a science... :P
Unless you can truthfully say your framework is/will-be different than the bulk of the others out there by a decent margin, I would seriously consider using someone elses existing and established framework
Well yes, they would be...as I would just be offering a DB abstraction layer, but an OR/M system and the template engine, uses drastically different techniques than anything out there today as far as I know and I've researched this intensely...but I'd need quite alot of other supporting classes, parsers, etc for this to work, which is why I'm troubled...as I don't exactly want to wait forever before I get started on this CMS :P
If you can't be bothered to learn their codestyle, build a "beautifier" to convert the code to your style. Although I will raise an "arrogance" flag at it, but won't do much worse than that
Considered that, but it's almost impossible...as I don't mean exclusively formatting, style, etc, although that's part of it...commenting, variable names, etc...all need the touch of a human...

I've read about TDD and I see it's usefulness...although I'm still not 100% convinced it's practical...to each to his own I suppose...

My problem is, that despite great deals of time spent planning, etc, I refactor code way to much to consider writing test cases for each object/function. I'm sure some might live past phase one, but every time I write a function I consider refactoring strategies, etc...

I'd be spending more time writing tests then writing code...which is where the discipline would come in, but the desire isn't there, yet anyways...

I write pretty compact functions and always look to further abstract a design, making debugging much easier and obsess quite a bit about a funciton returning expected results...thus making it harder for me to consider TDD as first round I usually get functions right as far as implementation is concerned. The TDD would come in handy for me when months later I modify some source code and have a green light go red, notifying me of a bug, instead of finding it the hard way, via user complaint, etc... :P

So for me, because of my obsession with writing a function right the first time...writing tests for functions, etc before I even write a single line of code would seem impractical, as I already spend greats deals of energy making sure their right...and the constant refactoring makes it difficult to keep synchronized...

I would MUCH prefer to use some kind of inline macro like ASSERT, so I could test in the implementation itself...I figure the runtime issues caused by tests is why PHP and other scripting languages use an external library/framework of sorts...

At least that's my understanding of the subject anyways... :)

Anyways the point is, writing PHP test cases goes against my very style of developing...where I plan alot, write a little, refactor, debug and repeat until I'm convinced the function handles every input properly according to plan.

I'm all for change, but the additional work load doesn't do the technique justice...whereas inline macros would be minimal to keep up to date...much like phpDocumentor comments...

What am I missing? Something else you can convince me on?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'll give you an example where unit tests help a lot recently: The IPv6 thread in Regex. While reading the RFC for IPv6 I wrote out tests for the various examples they showed. After I finished reading it, I looked at the originally posted, but failing regex based version. It looked pretty daunting. So instead of trying to figure it's logic out for hours and hours on end, I spent about 30 minutes building a variant of the final version I posted. Testing all the way, I knew it was working correctly. So I refactored a bit into the final version. Sure, it wasn't all that different from the first phase, but those tests made it a lot easier to spot when there were problems in how I adjusted the code.

When I posted it, I had completely forgotten about the original, pretty much, but Ambush asked about it. I was curious, now that I had a working one that was completely different where it was breaking. So I tested it, turns out it was off by a only a few parts of the regex, to become fully passing of my tests.

---
I adjust my coding style all the time, just like my signature and normal handwriting. I'm quite used to change and embrace it. I enjoy seeing the world from different perspectives. Forcing myself to work in someone else's code to produce something gives me a great understanding for how they think and understand things. Often I see bits that could use improvement, but I try to hold off final judgement until I've gone through everything and understand it from the ground up.

I do the same thing with cars too. :)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

arborint wrote:My not very humble and slightly belligerent opinion is that until to main thing that bothers a programmer is bad design they are not there yet. The thing I admire about programmers like feyd is that, while they will occasionally mention this or that thing that annoys the about code, their main focus -- like a laser beam -- is on the the design of the code: what's good and what need to be improved.
I'm missing something...my main focus in on the design :?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Using test cases (if I understand correctly) in the scenario would be analogous to stepping through your code with a debugger and watch variables...

Maybe that is the problem I have with test cases...perhaps I am so accustomed to Visual C++ IDE and it's powerful debugger, I can't justify using PHP testcases as it seems like a heck of alot of maintenance programming.

I suppose I could integrate that step into my daily breaks where I clean up documentation, code, etc...but...I'd just prefer to have things done like they are in a real IDE and language which supported preprocessor directives :)
I enjoy seeing the world from different perspectives. Forcing myself to work in someone else's code to produce something gives me a great understanding for how they think and understand things
Ditto :P

And I usually do refrain from fixing others code...but there are no time constraints (outside of my own desire to have a working CMS) and no one paying me to get something done...

I dunno man, don't you find you deal with the 2 situations differently? Personal projects and paid projects I mean??? I change my coding style as I find fit...for instance, i'm not sure I need hungarian notation in PHP scripts, but I use a loose variation of it still... :oops:

Coding style, for whatever reason, purely aesthetic perhaps, is important to me...if for any other reason, I like consistency...while embracing change...and herein lies the crux of the problem... :P

Nice, clean, consistent, well documented source code leaves me feeling positive and professional, which can only have a positive effect in the long run...

Yes I admit, when under pressure I sometimes take shortcuts and often use pre-existing libraries, hacking away as needed, etc...but i hate doing that for personal projects, as it's not nessecary and I'm a perfectionist I guess... :roll:

Sorry feyd if it seems like I'm doing nothing but arguing...please know that I'm not doing just that, but rather brain dumping all the days content in textual form for later rehashing...

I'm considering everything you say and others (arborint) regardless of whether it's positive or not...I always consume all criticism, whether it's constructive or not... :P

Edit: Somebody should write a PHP compiler-compiler (preprocessor), where the extended version of PHP would offer directives to emulate #define, etc... :P

Edit2: I've used third party libraries and controls for years in MFC and never had any problems using those, despite some being rediculously buggy :) I'm wondering if perhaps, it would be possible to compile and entire PHP source tree into a single PHP script, emulating a compiler...that would be neat...but I don't know how you would handle external resources, etc, like images...storing them inline with the code can't be a good idea...talk about obfuscating :P

Cheers :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Hockey wrote:I dunno man, don't you find you deal with the 2 situations differently? Personal projects and paid projects I mean???
No, I deal with them pretty much the same. I just move a lot slower with my own projects, because I have the luxury of time.
Hockey wrote:I change my coding style as I find fit...for instance, i'm not sure I need hungarian notation in PHP scripts, but I use a loose variation of it still...
I threw out hungarian several years ago. I've moved on to using descriptive, rarely abbreviated variable names. Names that actually mean something instead of the cryptics I used to use. I moved on while doing game programming. The only reminent of it now is $aName, which I picked up during my last job... "a" being for argument. As in they are only used for arguments to functions.
Hockey wrote:Coding style, for whatever reason, purely aesthetic perhaps, is important to me...if for any other reason, I like consistency...while embracing change...and herein lies the crux of the problem... :P
As long as it's indented properly (where blocks align in some useful pattern) I'm cool with whatever else. Pear coding, phpBB, JoesCrabs, doesn't matter, I can roll with it.
Hockey wrote:Yes I admit, when under pressure I sometimes take shortcuts and often use pre-existing libraries, hacking away as needed, etc...but i hate doing that for personal projects, as it's not nessecary and I'm a perfectionist I guess... :roll:
I guess that's a distinction between us. I write my code modular enough these days that most often, if I need to switch third party libraries, I just need to write a new Facade or wrapper. Hell, I even wrappered SimpleTest. Everything that's third party is wrapped. Now, if the client doesn't care, or doesn't pay for maintainence, I just code it straight if it's going to eat a lot of time.
Hockey wrote:Sorry feyd if it seems like I'm doing nothing but arguing...please know that I'm not doing just that, but rather brain dumping all the days content in textual form for later rehashing.

I'm considering everything you say and others (arborint) regardless of whether it's positive or not...I always consume all criticism, whether it's constructive or not... :P
No worries. I understand the place you're coming from.

edit: damned grammar.
Last edited by feyd on Wed Aug 16, 2006 11:28 pm, edited 1 time in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Hockey wrote:I'm missing something...my main focus in on the design :?
Maybe what you are missing is the fact that you can't see that your main focus in not on design, but on trivial things like formatting, style, commenting, variable names, etc.

I would make a strong recomendation that you reject your own style and embrace that of others -- it will set you free. I currently have client's sites running under Mojavi, Symphony, Cake, Zend, my own PHP framework, one on Ruby on Rails and a couple in Perl ... and quite honestly I don't think I have a programming style any more and couldn't be happier.
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Maybe what you are missing is the fact that you can't see that your main focus in not on design, but on trivial things like formatting, style, commenting, variable names, etc.
Ok fare enough, I assume you mean design at a structural/implementation level...??

Whereas I was being a little more vague, in that design covers not just planned design, but artistic design...

I will argue however, as we have in the past, that refering to coding conventions (formatting, style, commenting, variable names, etc) as trivial is somewhat naive...

They are equally as important as well planned, structured, modular, standardized practices which you always promote. ;)

Design patterns, in fact, I would argue are less important, as many applications have been designed without regard to existing design methodologies, whereas I know of zero successful applications which are developed and did not follow at least one of those so-called trivial things...

It's clear you and I fall from different trees and don't share many common opinions...

May I ask just out of curiousity...you strike me as a computer science graduate (or possibly still student) as you are quite educated on theory, yet seem to revolt against practical...at least you appear zealous towards what post secondary teaches you... :P

That and your advocating of Java when language comparisons some up, kind of pointed me to this conclusion???

Am I warm? or do I have cold feet? Are you completely self taught? Did you attend a 2 year technical college course? Are you an AI bot programmed to argue with everything I say? :lol:

How accurate is my synopsis? Am I the next Dr. Phil? No bald jokes...and plus I'm not over weight, but quite the contrary... 8)

Cheers :)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Hockey wrote:Ok fare enough, I assume you mean design at a structural/implementation level...??
To me, software design covers all levels.
Hockey wrote:Whereas I was being a little more vague, in that design covers not just planned design, but artistic design...

I will argue however, as we have in the past, that refering to coding conventions (formatting, style, commenting, variable names, etc) as trivial is somewhat naive...

They are equally as important as well planned, structured, modular, standardized practices which you always promote. ;)
I am really not sure what you mean by "artistic" but I assume that you mean creative. I think being creative with coding conventions is not only unimportant, but a dangerous waste of time -- whereas I think being creative in design is very important.
Hockey wrote:Am I warm? or do I have cold feet? Are you completely self taught? Did you attend a 2 year technical college course? Are you an AI bot programmed to argue with everything I say? :lol:
English Literature and Mechanical Engineering at university, but I started programming a 15-16. The one programming class I recall taking I thought was worthless because if mainly focused on coding conventions ... ;)
(#10850)
Post Reply