IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New A technique
First off - I'm a fan of named parameters - which is why I much prefer languages like ObjectiveC and Smalltalk as they name the params in the message names.

dict at: key put: anObject.

I name my java method names similarly

map.atKeyPutObject(key,object);

Yes they get looooong - but they are understandable.

longest method name I remember in the WebObjects api is

object addObject: anObject toBothSidesOfRelationshipWithKey: relationshipName;

Lately I've been running into situations where I've written a method and it does exactly what I want in 90% lf cases and I'm using it all over the code. Then I hit a case where it has to act just a tiny bit different.

So I add an additional parameter and extend the name of the original function, then reimplement the function to pass what would be the default parameter.

so I had product.addDemand(demandQuantity) throws UnsatisfiableDemandException

and then well into the project I learn that there is a case where you have to push the demand through regardless of whether you can satisfy it - which ended up with me changing the first method to:

product.addDemandForced(demandQuantity, shouldForce)

and creating

product.addDemand(demandQuantity) { addDemandForced(demandQuantity,false); }

Still clear what's going on and I don't have to touch the already written code that uses the usual behavior.




Smalltalk is dangerous. It is a drug. My advice to you would be don't try it; it could ruin your life. Once you take the time to learn it (to REALLY learn it) you will see that there is nothing out there (yet) to touch it. Of course, like all drugs, how dangerous it is depends on your character. It may be that once you've got to this stage you'll find it difficult (if not impossible) to "go back" to other languages and, if you are forced to, you might become an embittered character constantly muttering ascerbic comments under your breath. Who knows, you may even have to quit the software industry altogether because nothing else lives up to your new expectations.
--AndyBower
New That's pretty much what I'm trying to do.
Except that PHP doesn't natively support named paramaters - hence my trick.

The other thing I found is that after adding some option that that 10% needed, I would often find the function would now be useful in dozens more places and that that 10% was now 30% or more. Then I'd find another option needed and it would be even more useful. Until the original variant is now only being used 25% of the time and the latest option is being used 60%... :-)

Wade.

Is it enough to love
Is it enough to breathe
Somebody rip my heart out
And leave me here to bleed
 
Is it enough to die
Somebody save my life
I'd rather be Anything but Ordinary
Please

-- "Anything but Ordinary" by Avril Lavigne.

New Best Advice: Be merciless in your refactoring.
Often when that happens - the function in question really wants to be more functions thatt are called in various combinations.




Smalltalk is dangerous. It is a drug. My advice to you would be don't try it; it could ruin your life. Once you take the time to learn it (to REALLY learn it) you will see that there is nothing out there (yet) to touch it. Of course, like all drugs, how dangerous it is depends on your character. It may be that once you've got to this stage you'll find it difficult (if not impossible) to "go back" to other languages and, if you are forced to, you might become an embittered character constantly muttering ascerbic comments under your breath. Who knows, you may even have to quit the software industry altogether because nothing else lives up to your new expectations.
--AndyBower
New Re: Best Advice: Be merciless in your refactoring.
How do you decide this?

In math, one would often have a situation in which an "abstract language concept" - say templates in C++ - would present itself. Now, you see how IF IT REALLY WORKED this would be nice - I've made up an inner-product class and the spaces be damned! - but in the end, I would always opt for specific coding for speed and efficiency and ease of later use. This always works better - meaning - templates are not of any real use for an actual problem, because you have to also maintain the template.
-drl
New Its like cleaning house
You get a feel for things after awhile - but basically anytime you spot a chunk bigger than 2 lines long of nearly identical code, its time for a new function.

The other metric is that of a "thought".

Each thought should be a function/method/reusable thing.

The more advanced a program gets - the smaller it gets.



Smalltalk is dangerous. It is a drug. My advice to you would be don't try it; it could ruin your life. Once you take the time to learn it (to REALLY learn it) you will see that there is nothing out there (yet) to touch it. Of course, like all drugs, how dangerous it is depends on your character. It may be that once you've got to this stage you'll find it difficult (if not impossible) to "go back" to other languages and, if you are forced to, you might become an embittered character constantly muttering ascerbic comments under your breath. Who knows, you may even have to quit the software industry altogether because nothing else lives up to your new expectations.
--AndyBower
     Positional parameters vs. Named parameters. - (static) - (30)
         Is it possible to ... - (jbrabeck)
         Not sure i'd use a dictionary - (ChrisR) - (5)
             That last suggestion... - (admin)
             Problem with overloading - (drewk)
             To be honest, I don't know. - (static)
             Python cookbook example + discussion: - (FuManChu) - (1)
                 Interesting. Some good ideas there. -NT - (static)
         A technique - (tuberculosis) - (4)
             That's pretty much what I'm trying to do. - (static) - (3)
                 Best Advice: Be merciless in your refactoring. - (tuberculosis) - (2)
                     Re: Best Advice: Be merciless in your refactoring. - (deSitter) - (1)
                         Its like cleaning house - (tuberculosis)
         May be you have a class trying to get born - (Arkadiy)
         Can't say without code - (JayMehaffey) - (2)
             Define 'better' :-) [+ some examples] - (static) - (1)
                 Re: Define 'better' :-) [+ some examples] - (JayMehaffey)
         another solution - (tablizer) - (11)
             No, it's not. - (static) - (10)
                 That is more syntax - (tablizer) - (9)
                     OT: Bryce... - (folkert) - (1)
                         OT: I don't have access to receipt. On biz travel - (tablizer)
                     Also more limited - (JimWeirich) - (6)
                         There be XML -NT - (Arkadiy) - (1)
                             but XML "solves" the problem by not having variables -NT - (tablizer)
                         minor issues IMO - (tablizer) - (3)
                             I should have known. - (static)
                             Re: minor issues IMO - (JimWeirich) - (1)
                                 difference in style - (tablizer)
         I generally lean towards the hash solution - (ben_tilly) - (1)
             That's a good idea. - (static)

Why did my head just get farther away?
59 ms