Skip to content

Comment on Classes often aren't the simplest tool for the jobparent

Comments

There are things like static classes and functions that can co-exist.

Isn’t a static class essentially just a namespace?

Static classes still have constructors that gets invoked to create the static instance. Namespaces doesn't have constructors and instead each member of the namespace gets constructed separately.

I guess it depends on the language but I've definitely had problems with codebases that depended heavily on static initializers. IMO it's usually better to explicitly bootstrap your code.

Most developers aren't fully aware of how static initialization works so putting it in your code usually isn't a good idea even if you know it, no, but it is a difference between static classes and namespaces.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.