I was going to through this post by Mattt Thompson in which he mentions that

Static functions are nicer than shoe-horned class methods

I just don’t see any flaw with Class methods in Objective-C and I could not relate it to C based static functions. Is it something to do with the fact that Objective-C classes are itself objects of metaclasses?

2

Some languages such as Java have “static methods” that live in a class’s namespace, but do not use dynamic dispatch. Instead, they are dispatched statically at compile time (hence their name). Dynamic dispatch is less efficient than static dispatch, since we have to search for the method in all classes of the object we’re calling a method on. A central point of OOP is that we do not know the class of the object we’ll be calling methods on a priori.

In Java, the properties of static methods make them a good candidate in two use cases:

  • “Class methods” (which Java doesn’t have), e.g. some constructor with a better interface. These are problematic in Java since static methods can’t be inherited, and classes can’t be passed around as objects. The result is often an extra Factory object.

    Objective-C can use real class methods in these cases, which is welcome flexibility. After all, Objective-C has a metaobject protocol, and classes are objects.

  • Low-cost method calls. Since calling a statically dispatched method is much cheaper than invoking a dynamically dispatched method on an object, static methods can be used to optimize code.

    Since Objective-C builds upon the C language, we can always use plain old C functions. C does not have dynamic dispatch, and function calls are very efficient. However, C has no concepts of classes and namespaces, so great care has to be taken to avoid name clashes.

The object-oriented paradigm turns out to be very good at encapsulating complexity. While this makes it easier to design systems, it also makes it more difficult to reason about performance.

The point of the post you mentioned seems to be that using the C subset of Objective-C (i.e. the procedural features) can be a very good idea, since it contains a couple of sensible features the object-oriented parts of Objective-C won’t give you. The sentence “Static functions are nicer than shoe-horned class methods” is likely to mean that if you have some function that does not have to be an instance method, using a C function is probably a good – and certainly more performant – solution than putting it into a class method (which would also miss the point of classes-as-objects).

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật