LoginSignup
0
0

More than 3 years have passed since last update.

Python,Ruby(及び型が明示されていない言語)が糞だと思う点

Last updated at Posted at 2020-01-03

ソースリーディングをしていて以下のようなコードに出くわした時

class BaseRequestHandler:

    """Base class for request handler classes.
    This class is instantiated for each request to be handled.  The
    constructor sets the instance variables request, client_address
    and server, and then calls the handle() method.  To implement a
    specific service, all you need to do is to derive a class which
    defines a handle() method.
    The handle() method can find the request as self.request, the
    client address as self.client_address, and the server (in case it
    needs access to per-server information) as self.server.  Since a
    separate instance is created for each request, the handle() method
    can define other arbitrary instance variables.
    """

    def __init__(self, request, client_address, server):
        self.request = request
        self.client_address = client_address
        self.server = server
        self.setup()
        try:
            self.handle()
        finally:
            self.finish()

request, client_address, serverってなんやねんってなる。
このコードを書いた人はある特定の型のオブジェクトがここに突っ込まれることを想定していると思う。でも型が明示されていない為それが何なのか分からない。呼び出す側を探してそれが何なのか確認しなきゃならない。
コードを書いている人の脳内にある型の情報がソースコード上では省略されているからこんなことになる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0