Opened 12 years ago

Closed 7 years ago

#5475 closed enhancement (invalid)

Eliminate ways of circumventing the Color constructor

Reported by: ptwobrussell Owned by: ptwobrussell
Priority: low Milestone: 1.7
Component: Core Version: 1.0
Keywords: needsreview Cc: ptwobrussell@…
Blocked By: Blocking:

Description (last modified by bill)

From my read of Color.js, it seems like the API would benefit from eliminating the exposed dojo.colorFromRgb, dojo.colorFromHex, and dojo.colorFromArray functions and instead sticking them inside of the class itself. I'm sort of confused by the way that these methods allow you to circumvent the Color constructor itself, and I believe that the API would be a lot more crisp if you just used the Color constructor directly.

My recommendation is to tuck these methods inside of the Color class for Dojo 2.0.

If I've really missed something here (entirely possible) can you include a descriptive message which explains why these functions *should* be exposed, so that I can better present them in the book I'm writing -- because right now, I'm planning on skipping over them entirely for the reasons mentioned.

I don't know who else to assign to, so i looked at the revision log and noticed that elazutkin seems to be the maintainer, so I'll start there.

Change History (7)

comment:1 Changed 12 years ago by ptwobrussell

Actually, one more thing: I also don't understand the use case for why you'd pass a Color object to use the Color constructor to create a new Color object. Again, I'm intrigued and would love to know about an interesting use case for what seems like this "special" clone operation, but I really can't think of one or find one anywhere. Assuming you agree, perhaps this should be axed as well?

comment:2 Changed 12 years ago by Eugene Lazutkin

Owner: changed from Eugene Lazutkin to alex

I don't have an answer for this --- I was not the original author, so I preserved the existing API whne I did a clean up. I am reassigning it to Alex to make the call.

comment:3 Changed 12 years ago by alex

Milestone: 2.01.3

Milestone 2.0 deleted

comment:4 Changed 11 years ago by bill

Description: modified (diff)
Milestone: 1.32.0
Owner: changed from alex to James Burke

comment:5 Changed 8 years ago by ben hockey

Keywords: needsreview added
Priority: highlow

comment:6 Changed 8 years ago by bill

Milestone: 2.01.7
Owner: changed from James Burke to ptwobrussell
Status: newpending

In the AMD conversion I had to make these factory methods off the module/class itself, ex:

require(["dojo/_base/Color"], function(Color){
   var myColor = Color.fromRgb(...);
});

Certainly, the equivalent methods on the dojo global should and will be removed in 2.0.

That's a bit different than the title of this ticket though, about "Eliminate ways of circumventing the Color constructor". Are you opposed to factory methods for some reason? Or is what I did above what you wanted? If it is, then we can mark this as fixed in 1.7.

comment:7 Changed 7 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.