Large API vs Builder like API

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Large API vs Builder like API

abergel
Hi!

It would be great to get feedback from you guys. 
We have the class TRConstraint that allows for roassal elements to be aligned (cf Section 10 in https://dl.dropboxusercontent.com/u/31543901/AgileVisualization/Roassal/0104-Roassal.html). 

Currently, you can write: 
TRConstraint use: centralDot alignFromTop: negativeElements

Which align all the elements contained in the collection negativeElements against a fix point, centralDot.
It looks pretty easy to read. However, the class TRConstraint has many methods (alignFromBottom:, alignFromLeft:, use: aShape alignFromBottom: shapes, …) which are essentially all duplicated code.

So, I though about creating a compact class, called RTAlignment. You can now write:
RTAlignment new elements: negativeElements; fixedElement: centralDot; top

But, I find that less nice to read. Any opinion?

Cheers,
Alexandre
-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
cbc
Reply | Threaded
Open this post in threaded view
|

Re: Large API vs Builder like API

cbc
On Fri, Jul 31, 2015 at 2:34 PM, Alexandre Bergel <[hidden email]> wrote:
Hi!

It would be great to get feedback from you guys. 
We have the class TRConstraint that allows for roassal elements to be aligned (cf Section 10 in https://dl.dropboxusercontent.com/u/31543901/AgileVisualization/Roassal/0104-Roassal.html). 

Currently, you can write: 
TRConstraint use: centralDot alignFromTop: negativeElements

Which align all the elements contained in the collection negativeElements against a fix point, centralDot.
It looks pretty easy to read. However, the class TRConstraint has many methods (alignFromBottom:, alignFromLeft:, use: aShape alignFromBottom: shapes, …) which are essentially all duplicated code.

So, I though about creating a compact class, called RTAlignment. You can now write:
RTAlignment new elements: negativeElements; fixedElement: centralDot; top

But, I find that less nice to read. Any opinion?

Cheers,
Alexandre

TRConstraing align: negativeElements using: (RTAlignment top against: centralDot)


From your original list, I'd be more likely to want to use your first example.  But then, I'm used to lots of methods.

-cbc

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Large API vs Builder like API

jfabry
In reply to this post by abergel
Hola,

the RTAlignment solution is more in line to what is happening with Roassal in general, e.g. you make a shape and then set different properties via different 1-argument keyword messages. So for consistency I would expect that (together with some sensible defaults) instead of the current API of TRConstraint.

On Jul 31, 2015, at 18:34, Alexandre Bergel <[hidden email]> wrote:

Hi!

It would be great to get feedback from you guys. 
We have the class TRConstraint that allows for roassal elements to be aligned (cf Section 10 in https://dl.dropboxusercontent.com/u/31543901/AgileVisualization/Roassal/0104-Roassal.html). 

Currently, you can write: 
TRConstraint use: centralDot alignFromTop: negativeElements

Which align all the elements contained in the collection negativeElements against a fix point, centralDot.
It looks pretty easy to read. However, the class TRConstraint has many methods (alignFromBottom:, alignFromLeft:, use: aShape alignFromBottom: shapes, …) which are essentially all duplicated code.

So, I though about creating a compact class, called RTAlignment. You can now write:
RTAlignment new elements: negativeElements; fixedElement: centralDot; top

But, I find that less nice to read. Any opinion?

Cheers,
Alexandre
-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev



---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev