开发者

Programming languages: out of the box legibility and extensibility

开发者 https://www.devze.com 2023-02-02 05:39 出处:网络
Two excellent results of SOLID development ideology are -Legibility -Extensibility over the life of a project (http://en.m.wikipedia.org/wiki/Solid_(object-oriented_design)

Two excellent results of SOLID development ideology are

- Legibility

- Extensibility

over the life of a project (http://en.m.wikipedia.org/wiki/Solid_(object-oriented_design)

Although SOLID is a set of language-agnostic design ideas, s开发者_StackOverflow中文版ome languages inherently support these ideas better than others. Out-of-the-box or after various customizations, in your opinion which language is best-suited to be both easily readable and easy to extend functionality in?

Some definitions to pre-empt biases and flamewars:

  • Legibility: amount of thinking done to understand the code proportional to the amount of code: (amount_think-energy / amount_code) is fairly constant and as low as possible in the optimal case.
  • Extensibility: Addition of X amount of functionality requires a change in code or code additions in proportion to X (amount_added_functionality / amount_added_code) is fairly constant and as high as possible in the optimal case.

Supporting information and tutorials encouraged. Code snippets welcome.


I could list everything on this page but just click it to read all about the awesomeness of D.

(As inclined as I am to say that this is completely objective, it probably isn't... but it should still give you a good view of the features of D.)


Python. It's concise, but not cryptic. It avoids overuse of symbols (or and and instead of || and &&, and so forth, plus no curly braces), it must be indented consistently throughout (making structure far more apparent), it's dynamically typed (preventing some of the head scratching moments caused by casting variables, overloading, etc.). Python also makes it easy to make custom objects behave more like builtin types with magic methods(for example, I can define a __add__ method and add two instances of my object just like I would add integers).

Python's object-oriented syntax is very flexible. Magic methods make virtually anything possible with Python classes with little effort. For example, if I wanted to make an object callable, all I'd have to do is this:

class SomeClass:
    # rest of class implementation here

    def __call__(self):
        # define some behavior for when the object is called

I don't have to do anything funky; it's a standard procedure and it requires minimal change to the code.

Moreover, since Python has a very comprehensive standard library, little reinventing of the wheel is done, which again allows huge amounts of functionality to be adding with almost no new code being written.

There are plenty more reasons why Python is legible and extensible, and there are plenty of other languages that are just as good for SOLID. I just thought I'd weigh in for my favorite language.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号