Progressive enhancement usually refers to web content, and the idea of having a page that is readable before it's fully functional.I'm suddenly preoccupied with the idea that I can't progressively enhance my code. I want to be able to add methods to my values. I might have a string property. If I want to enhance it with an IsValid() method, I've no way of doing that without changing the caller. On one hand, this seems inevitable. I used to have a string. Now I've got an object with a string value and some methods. It's a totally different type, and I have to call it differently.But, the reality I'm modelling hasn't changed. I've just gotten around to adding IsValid(). Why should existing callers who just want the value (and don't care about validity) have to adapt? C# has the notion of default properties, where, you can address a collection property just by providing the containing class and the index. So you could change a List into SomeClassWithAListInside without the caller caring. Why can there be no equivalent for other types of properties? Do other languages deal with this differently?
Progressive Enhancement as a language feature
object oriented design;modelling
You can add new methods to all classes which you control, and if you don't control a class, you can provide a subclass which support the new methods, and this will be transparent to any caller.So the issue you describe is only an issue if you want to extend a class which you don't control and which is sealed so it cant be subclassed - like String in some languages. String and primitives are sealed as a compromise for performance in these languages, so either you should change to a more flexible language, or you should avoid exposing domain objects in the form of primitives in the first place.Some dynamic languages like Python and JavaScript allows you to extend arbitrary objects with new methods, which is called monkey patching. This kind of solves your issue, but is generally a bad idea because you risk clashes, and because when you turn say a string into a domain object, you will turn every string in the program into this domain object which is obviously crazy. Extension methods in C# is a different approach which avoids clashes, but still have the fundamental problem that is will apply to all instances of the extended type.