class - Does anyone design api or library code in this way? -


I was reading a few things about designing a library or API, and Joshua Bloch in Google Tech Stumbled into the great speech of Talks. Now though I am not with a professional API developer, I feel that programming is similar to a bunch of classes / functions, although a much smaller version of the same thing - a clear cut, easy and pleasant use of the verb, clean code Encourage, etc.

I was going through some widely used open source Java code and got this idea (nothing is new, but just putting it clearly ...)

Let us have an example pseudo-code (or maybe a few bids of the default bid):

  1 new Label 2. Set name 'Hello World' 3. Set color 'blue' 4. Show 'topmost' 5. Click on hide  

Now get inspired by Java code I want to some :

  1 label l = new label () 2. .SetName ('Hello World') 3.SetColor ('blue') 4. .show (zindex.top); 5. l.onClick = l.hide ();  

My question is: does someone design an API that starts with another pseudo code?

Is this a good idea for something small? Speak up to 10 squares with maybe 10 ways, each method is no more than 5-6 line codes. It is obvious that in order to design the size of the class, there is to show a thick group of numbers - anywhere close to a full API and not just a hobby project - a professional package which makes small but it is well .

Has anyone seen any serious drawbacks on this approach?

I think a real benefit is that forces you to write matters before use .

The other thing is that nouns and actions are simplified , to which your final product is multiplex demonstration design paradigm. syndrome: - D

< / Div>

This is a normal design pattern given a name. It is common in functional languages ​​and is gaining popularity somewhere else. I saw it in the first plan.

This is a very convenient and readable idiom, but remember that there will be times when you actually want to start more than one variable in a function call. For example, when there is an internal situation that should be set based on the combination of data, or when default values ​​are set and overwriting is expensive, therefore, as with all "patterns", use it with prudent and forethought .


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -