rich Posted March 29, 2013 Author Share Posted March 29, 2013 No we can't use that method, you'd get no documentation / code insight support from your IDE if it was all bundled under a single method. Equally the amount of conditionals we'd within those two methods would be huge. Nice approach, but not suitable for our needs. Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted March 29, 2013 Share Posted March 29, 2013 I just don't support IE7/8 Quote Link to comment Share on other sites More sharing options...
Chris Posted March 29, 2013 Share Posted March 29, 2013 Why do you need getters/setzers in the first place? Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted March 29, 2013 Share Posted March 29, 2013 Um, I answered that before. Because If you will need additional validation or operation on value, then you would have to replace every assignement. obj.x = 1 to setX(1) // orset('x', 1) Quote Link to comment Share on other sites More sharing options...
Chris Posted March 29, 2013 Share Posted March 29, 2013 I know the general concept behind getters/setters I mean why does @rich specifically need them. Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted March 29, 2013 Share Posted March 29, 2013 Oh, ok. But I think no specifics are needed. You use setter/getters to leave yourself open doors if you will eventually need additional operation on set/get. Other way you would have to replace assingments in whole project just to check for example if passed value is a string, it would be really painfull. Quote Link to comment Share on other sites More sharing options...
Chris Posted March 29, 2013 Share Posted March 29, 2013 I still think Backbones approach is better, since you can have one basic model that you extend/adapt to all objects you might need.Yes, some IDEs might not be able to support code completion for those attributes, but I develop very complex applications upon backbone and never missed attribute completion in the get/set methods.If you really forgot what attributes an object has you take a look into the docs or on the objects 'defaults' property which should hold all default attributes of an object.Also you dont need to use any conditionals in the set method to validate your incoming values. Again, take a look at backbones validation approach, they don't use conditionals, either.The best would be to not validate at all (by default), because its slow. Quote Link to comment Share on other sites More sharing options...
rich Posted March 29, 2013 Author Share Posted March 29, 2013 If you don't validate the parameter given you run the risk of creating random properties on the base object, assigning who knows what to them. Equally using strings to set them opens up plenty of chances for code typos, and I still don't see how documentation generation would be cleanly split up? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.