|
Monday, December 18, 2006
Reusability is in the idea, not the code
In Flash programming, perhaps more than in any other kind of web programming, people seem to be code-reuse-happy. Maybe that's because ActionScript has the capabilities of doing more things than most other languages. We can create data models and write controller logic with the same languages that can make a bitmap blur, fade, and spin. There's so much breadth to ActionScript that we instantly look to see what bit of code we (or someone else) wrote way back when to do that very particular thing we need to do today.
So, often is the time that I'm asked if a certain bit of code is reusable. "Can we reuse this codebase to make the very same XYZ as that XYZ? Only...with these 11 minor differences? I instantly cringe. Because, in reality, all code is reusable. You just copy the codebase over from one folder to another and poof, we've reused it! Slap on 11 hacks and you've got yourself a nice new duct-taped application thank you very much. Reuse is in the idea behind the code, not the code itself. In fact, when I develop, I don't think in terms of whether this class or that class is reusable, but I think of whether the general idea behind why I wrote this or that class is reusable. Some might call the general idea a design pattern. At Xoprecious, we're constantly updating and modifying our library of reusable code. In doing so, I've found that truly reusable code does less. It interferes less with the application. It sits on the sidelines with an occasional helping hand as I steer through the logic mainly on my own. The amount of code you write has little to do with how hard it is to write that code. In fact, I find that the more unique code I have to write around my reusable code, the better I understand what's going on. I've had the reverse case happen all to often...letting reused code structure the vast majority of the application. Meanwhile, I'm steering through an unsettling amount of code I'm not truly familiar with, hoping that I can chip away and add on bits of syntax here and there without letting the whole ship fall apart. Here's an example. Recently, we decided to build a reusable code base for Flash forms. The idea here was to figure out a nice way to handle form validation management. In Chapter 8 of our book, we write an interesting technique to handle validation. The code itself contains a form validation manager, tracking the form parts that need validation and lets you assign different validation strategies (class instances that handle validation, like a number validator or required field validator) to different UI components. These components were linked to custom wrapper classes that expected every form component to have a label, a form element (like a radio button or text field) and an area for validation alerts. All fine and dandy, but what if I wanted to not have validation alerts pop up next to each form element? What if I wanted to just write out all validation flags in one dedicated spot when a user hits submit? What if I wanted the form component to pulsate red when it didn't validate? If we had simply reused this codebase as is, it would've been a whole lot of rewiring to figure out how to hack the current structure. Instead, I rebuilt the codebase for forms. The new codebase unties the visual cues from the validation. Each form element that needs validation has to add itself to the form validation manager as it did previously, but now, you provide the validation manager with a callback function after validation is run against it. The callback functions, which you have to custom create each time you write a new form, can obviously do what it pleases. In theory, it seems like more work. The reusable code has been reduced to just a bunch of validation classes and one manager, and the work of deciding what to do with the validation information has to be done each time you write a new form. But, this is what makes the code truly reusable. The idea behind it is that it lets you code your form in exactly the way you want, lending a helping hand when you want to check that a number is between 1 and 100, an email is in the correct format, or that a text field has data in it. The reusable code does not tell you what you should do with that information at all. It's job is simply to manage what you want to have validated, and let you know how that validation went. What you do with that information is up to you. Now, perhaps, 6 out of 7 times, I might want the rigidity of what the original Chapter 8 code offers. But, still, by letting the reusable bits do less, I instantly get more familiar with the actual application I'm working on rather than feel less intimate with it because the reusable code is doing more. I think truly reusable code follows this litmus test: When you reuse code, does it make you understand how your code works less than if you wrote it from scratch? In the case of the new form libraries I've written, it passes. I know what its purpose is and I know where it gets out of the way, letting me write (and understand) all the unique parts of my application. |
||||
5 Comments:
Great site
http://home-forclosure.eticketsontime.com home forclosure
http://beaded-bracelet.eurocarexpert.com beaded bracelet
http://bathroom-lighting.casinogamefactory.com bathroom lighting
http://chicago-single.casinogamefactory.com chicago single
http://silk-scarf.eurocarexpert.com silk scarf
http://diet-points.asapdeals.com diet points
http://garden-furniture.boulevardprivates.com garden furniture
http://chicago-florist.kisswings.com chicago florist
http://tote-bag.eurocarexpert.com tote bag
http://cpa-course.lysog.info cpa course
http://folding-table.lysog.info folding table
http://replica-handbag.lysog.info replica handbag
http://altima-nissan.lysog.info altima nissan
http://gym-bag.malig.info gym bag
http://adhd-treatment.malig.info adhd treatment
Thanks.
"Lord, I have a problem!"
"What's the problem, Eve?"
"Lord, I know you've created me and have provided this beautiful garden and all of these wonderful animals and that hilarious comedy snake, but I'm just not happy."
"Why is that, Eve?" came the reply from above.
"Lord, I am lonely. And I'm sick to death of apples." "Well, Eve, in that case, I have a solution. I shall create a man for you."
"What's a 'man,' Lord?"
"This man will be a flawed creature, with aggressive tendencies, an enormous ego and an inability to empathize or listen to you properly, he'll basically give you a hard time. He'll be bigger, faster, and more muscular than you. He'll be really good at fighting and kicking a ball about and hunting fleet-footed ruminants, But, he'll be pretty good in the sack."
"I can put up with that," says Eve, with an ironically raised eyebrow.
"Yeah well, he's better than a poke in the eye with a burnt stick. But, there is one condition."
"What's that, Lord?"
"You'll have to let him believe that I made him first."
:D :D :D
_____________________________
shemale beauty sex
Hello guys, maybe i shoul sell my collection? to earn some extra cash. Here are some links from my base:
amateur free free sex
anal bisexual free fuck movie xxx
anal free gay in jail sex
anal anal ass free fuck sex video
free big black ass sex
asian free gallery pic sex
asian free pic sex video
free classic mature s
ex movie
ass big bigtitsroundasses.com ro
amateur free gay sex
archive free gay sex story
cartoon free gay movie post sex
clip free sex teenager
chat free lesbian sex
free-lesbian-sex.sexonmovies.info/first-free-her-lesbian-sex-trailer.html>first free her lesbian sex trailer
free hairy pussy sex movie
Who can help me with .httpaccess ?
where i can fined full information about .httpaccess file syntaxis?
I'd like to untroduce my home video
amateur free fucking homemade movie real sex
anal big black cock free movie sex
anal black free porn sex
anal free gothic pic sex
free indian indiana number passion picture sex site
asian cam chat free live sex
b
londe free mature sex video
clip free mature milf movie old sex xxx
free hairy mature pic sexy woman
big chinese tits
asian free gay sex
bi free movie sexual teen
chat free online sex teen
dominate erotic free lesbian sex story
free hairy picture sex
free hairy sex movie
Post a Comment
Links to this post:
Create a Link
<< Home