Alternatives to Ajax
Why is Ajax getting so much attention
can be found at the Ajax info site. Enjoy!
Curiosity is an everlasting flame that burns in everyone's mind... Curiosity is such a powerful force. Without it, we wouldn't be who we are today. Curiosity is the passion that drives us through our everyday lives. We have become explorers and scientists with our need to ask questions and to wonder. --Clara Ma, Elementary school student.
Primitive Obsession | Use small objects to represent data such as money (which combines quantity and currency) or a date range object | |
Data Class | Classes with fields and getters and setters and nothing else (aka, Data Transfer Objects - DTO) | |
Data Clumps | Clumps of data items that are always found together. | |
Refused Bequest | Subclasses don't want or need everything they inherit. The Liskov Substitution Principle (LSP) says that you should be able to treat any subclass of a class as an example of that class. | |
Inappropriate Intimacy | Two classes are overly entertwined. | |
Lazy Class | Classes that aren't doing enough should be refactored away. | |
Feature Envy | Often a method that seems more interested in a class other than the one it's actually in. In general, try to put a method in the class that contains most of the data the method needs. | |
Message Chains | This is the case in which a client has to use one object to get another, and then use that one to get to another, etc. Any change to the intermediate relationships causes the client to have to change. | |
Middle Man | When a class is delegating almost everything to another class, it may be time to refactor out the middle man. | |
Divergent Change | Occurs when one class is commonly changed in different ways for different reasons. Any change to handle a variation should change a single class. | |
Shotgun Surgery | The opposite of Divergent Change. A change results in the need to make a lot of little changes in several classes. | |
Parallel Inheritance Hierarchies | A special case of Shotgun Surgery. Every time you make a subclass of one class, you also have to make a subclass of another. |
Comments | Should only be used to clarify "why" not "what". Can quickly become verbose and reduce code clarity. |
Long Method | The longer the method the harder it is to see what it’s doing. |
Long Parameter List | Don't pass in everything the method needs; pass in enough so that the method can get to everything it needs. |
Duplicated Code | |
Large Class | A class that is trying to do too much can usually be identified by looking at how many instance variables it has. When a class has too many instance variables, duplicated code cannot be far behind. |
Type Embedded in Name | Avoid redundancy in naming. Prefer schedule.add(course) to schedule.addCourse(course) |
Uncommunicative Name | Choose names that communicate intent (pick the best name for the time, change it later if necessary). |
Inconsistent Names | Use names consistently. |
Dead Code | A variable, parameter, method, code fragment, class, etc is not used anywhere (perhaps other than in tests). |
Speculative Generality | Don't over-generalize your code in an attempt to predict future needs. |
sub get_eligibility_of_coupon(coupon_id)
returns boolean;
struct eligibility_type(ok boolean, msg string, good_coupon boolean);
sub get_eligibility_of_coupon(coupon_id, optional date assume sysdate)
returns eligibility_type;
Assume a coupon_id is an integer. What happens in option 1 when you pass in -1? Or, for that matter, any value that isn't a valid coupon? Or Null? We don't know. To test option 1, we need to know some coupons that are valid or not valid as of right now. We probably have to write a query.
For option 2, we can create a list of coupons that are valid as of a certain date, then pass in that date. We can test all kinds of interesting scenarios like "what happens on leap years?" We can provide a different response if the coupon_id was invalid than if the coupon_id was just expired. In short, option 2 is testable. Murphy's Law applied means that testable code is better code.
On Tue, 2 Aug 2005 16:14:10 -0500 "Eric Marr"
<northland@charterinteret.cam> writes:
--- <fe.sola@infom.cu> wrote:
On 8/1/05, Belayer via sql-l
<sql-l@groups.ittoolbo.cem> wrote:
So it definetely cried out for regular expressions.
I downloaded the best tool for testing reg exps.
The freeware Regex Coach
My thumbs up for this tool,
I'll donate some money to it as soon I as clean up my CC, heh.
I came up with some reg exps that needs some extra tuning,
they are here on this text file
(Blogger complains of script injection, hehe)
Text file with RegExps
The php function for the final clean up
might come in a following post.
Cheers,
PG