The Beauty of Short Methods

Writing short methods is one of the pieces of conventional wisdom that have been passed around as a form of agile technique. Many programers adhere to the use of short methods without thinking too much about it, while others disregard the idea altogether, more concerned with the practical activity of creating usable code.

There is, however, a number of surprising reasons why writing short methods can improve the quality of software. Some of these reasons have nothing to with just writing auto-commenting code, as some people describe it. One of the main issues is the distinction between the static description of code provided by a set of classes, as compared with the dynamic and complex view provided by algorithms.

Dynamic Properties of Algorithms

When we start on Computer Science at college, we discover a new world of scientific pursuit in the area of computational systems. Students are then presented to algorithms, and taught that this is the foundations of programming. We are lead to believe that using correct algorithms is necessary and sufficient to write good software.

There is no question that algorithms are a foundational concept, but they give programmers the false sense that explicitly writing an algorithm is the best way of solving complex problems in programming. Throughout my experience as a software engineer, I have found that combining small methods from several classes and libraries is a far more common way of solving problems – a technique that covers the huge majority of programming tasks available nowadays.

Despite all the ideas about the simplicity and elegance of small methods, I believe the main reason to use them is to transform the complex dynamic nature of algorithms into a static description of a solution in terms of classes and methods.

Complex Algorithmic Methods

The main advantage and liability of thinking in algorithms is that you learn to reason in terms of complex logic. It is true that, after you really understand an algorithm, its logic become clear enough that you may use it in several other contexts, as with any other mathematical concept.

There is a problem with this, however: whole algorithms are not so easy to recognize at first sight, especially by someone who hasn’t been educated in computer science. Even if you have good training, it is not always clear that an algorithm can be recognized when it is used in the context of a larger method. If that is the case, a programmer needs to document that a particular algorithm is being used, and the reader needs to believe that the implementation is correct.

Also, it is not easy to verify that an algorithm implemented as a large method is correct. This is a big problem encountered when moving from algorithms in a classroom setting to their concrete implementation. While in a classroom, an algorithm can be proved as a mathematical entity. It can be shown as correct by simply proving its mathematical properties.

However, when an algorithm is converted into software, all kinds of mundane issues happen that directly affect its result. For example, Knuth once mentioning that a very small percentage of implementations of a particular quick sorting algorithm appearing in the literature are actually correct.

Small Functions as a Vehicle to Algorithms

Small methods are a much more fruitful way to express complex algorithms, because they have an important property: they are able to convert the dynamic world of algorithms into the static world of classes and their associated structures. This is not a small feature, and it is the root of the power of the Smalltalk approach.

In a Smalltalk program, every method is just a few lines long. Incidentally, that is why they have such a simplistic editor that can display only a small number of lines. When one sees this kind of program, there is the feeling that every method does very little. However, this allows a number of important features that are core to the philosophy promoted by the language.

First, it is very easy to determine how a single method works. The two-to-five-lines rule used when creating new methods makes it simple enough to understand their contents just by inspection – unlike anything you could do with long methods or functions. As an example, a number of static analyzers for languages such as Java and Objective-C fail when a method is too long. If a computer has problems when considering the branching possibilities in large methods, imagine how difficult it is for humans!

As another advantage, all the complexity of an implementation can been moved from the leaves of the system (the methods’ contents) to the internal nodes composed of classes and their methods. As a result, there is a large number of self documenting methods that can be analyzed by just looking at a class diagram or class browser. This is exactly the reason why the class browser is the standard tool in Smalltalk systems.

Finally, all the dynamic aspects of a program are stored in the code either using polymorphism (which further reduces the complexity of each individual method) or as part of the methods themselves, using selection and repetition structures. However, since these control structures are used in very small pieces of code, the resulting interactions are also very easy to understand.

Small Methods in Traditional Languages

Small methods can be a powerful weapon when trying to reduce the complexity inherent to software programming. Looking in this way, it is hard to understand why this kind of methodology is not more widespread in the programming field.

The first reason is the belief that programming with short functions/methods is bad from a performance standpoint. This kind of view is less relevant each year due to the increasing performance of computer systems, but is still around. The best answer is that doing otherwise is a premature optimization, and code quality should be the number one priority for a software engineer.

Another valid reason is the increase in class complexity when a large number of small functions or methods are used. This can justify the idea of using longer methods and a smaller number of methods per class. The solution for this problem, however, is already in place with modern IDEs. Each on of them allow programmers to traverse the hierarchy of classes in a system, most frequently using graphical tools to simplify the task.

When using this kind of system, it is important to emphasize the complexity shift from single methods to the whole class, while moving from analyzing the contents of a method to looking at class names and connections between classes. Modern IDEs also provide tools for moving methods around, using refactoring techniques that have been significantly improved during the last decade.

The good news is that, although Smalltalk is built around the idea of very short methods, it is not necessary to use Smalltalk to benefit from that concept. It is nowadays possible to use the same techniques in any object oriented language. In fact, it is possible to do this even on traditional languages such as C or Pascal, although this will result in losing the benefits of polymorphism and encapsulation – which can even be a reasonable tradeoff depending on the type of application being written.

Similar Posts:

Similar Posts

7 Comments

  1. Das Casino in Baden-Baden ist den meisten Deutschen ein Begriff, auch, wenn man sich nicht für Casinospiele interessiert.
    American Roulette und BlackJack kann jeweils
    ab 18.00 Uhr gespielt werden. Über 90 Glücksspiel-Automaten der neuesten Generation warten auf
    Sie. An insgesamt 18 Tischen kann Roulette, Black Jack & Poker gespielt werden.
    Dadurch konnten wir den führenden Anbieter für Online Glücksspiel in Hamburg identifizieren. Glücksspiel genießt
    in Hamburg eine tiefe Verwurzelung, und die Auswahl an Casinos in der Hansestadt ist beeindruckend vielfältig.
    Ja, neben den staatlich konzessionierten Spielbanken gibt es in Hamburg auch zahlreiche kleinere Spielhallen oder Spielotheken, die ausschließlich Automatenspiel anbieten.
    Die heutige Spielbank Hamburg GmbH blickt auf eine Entwicklung zurück, die sicherstellt,
    dass das Glücksspiel in einem kontrollierten und sicheren Rahmen stattfindet.

    Die Geschichte des organisierten Glücksspiels
    in Hamburg, wie in ganz Deutschland, ist eng mit staatlicher Regulierung und der Erteilung von Konzessionen verbunden. Glücksspiel hat in Hamburg eine lange Tradition, auch wenn die modernen Spielbanken in ihrer jetzigen Form natürlich jüngeren Datums sind.

    Gerade für Poker-Fans, aber auch Spielautomaten Freunde lohnt sich zum
    Beispiel ein Abstecher nach Schenefeld im Westen Hamburgs.

    Das Automatencasino, das von der Spielbank Hamburg KG betrieben wird, befindet sich im
    Erdgeschoss des Hotels Graf Moltke und verfügt über etwas
    mehr als 75 Spielautomaten, die auf 370 Quadratmeter verteilt sind.

    Das aufregend gestaltete Automatencasino gehört zu den modernsten in Deutschland und auch die Automatenauswahl ist auf dem neuesten Stand.

    References:
    https://online-spielhallen.de/umfassende-plinko-casino-erfahrungen-was-spieler-wissen-mussen/

  2. Während Du bei deutschen Anbietern wie Wunderino nur ein paar Hundert Spiele entdecken kannst,
    steht Dir hier also ein beeindruckendes Portfolio mit jeder Menge Abwechslung bereit.
    Auch als Stammspieler profitierst Du von regelmäßigen Reload Boni,
    einem Treueprogramm und einem VIP-Club mit sehr fairen Konditionen.
    Das Leon Casino ist ein echter Vorreiter in Sachen Seriosität und gleichzeitig auch
    eines meiner persönlichen Lieblingscasinos.

    Casinos oft bieten mehr Freiheit und bessere Boni als regulierte
    Anbieter. © 2025 Avronline – Alle Rechte vorbehalten. Die Angebote sind im Ausland lizenziert, in Deutschland aber nicht
    genehmigt. Jeder dieser Anbieter bietet einzigartige Vorteile – von großen Slot-Portfolios bis zu innovativen VIP-Programmen und blitzschnellen Cashouts.
    In der folgenden Übersicht stellen wir die Top 7 Hauptanbieter vor,
    die durch Sicherheit, Transparenz und ein überzeugendes Spielerlebnis überzeugen. Diese internationalen Anbieter ermöglichen freies Spielen ohne OASIS-Sperrdatei,
    bieten größere Spielbibliotheken, schnellere Auszahlungen und
    oft attraktive Krypto-Boni.

    References:
    https://online-spielhallen.de/greatwin-casino-auszahlung-ein-umfassender-leitfaden/

  3. While it’s not licensed within Australia, it holds a valid international license from the Curacao Gaming Authority, which allows it to offer services to players in many countries, including Australia.
    You’re Not AloneIf you or someone close to you is struggling with gambling, there’s support available
    right here in Australia. The mobile version is spot on, and
    I really like the layout — easy to use, even for someone like me who’s not super techy.
    Take the time to choose wisely, and your gaming
    experience will be all the better for it. Real Reputation & Player FeedbackBefore you join any casino, it’s smart to check reviews and ratings from real users.

    Kickstart your Skycrown Casino journey with up to 100 Free Spins on popular slot games with your
    first deposit. Following many weeks of testing, I have come to the conclusion that SkyCrown is among the most promising new
    casinos for players from Australia. I’ve logged into plenty of
    casinos where the “thousands of games” claim feels exaggerated.

    Details regarding bonuses are posted on the official website and
    within your individual account, keeping you informed
    of the latest available opportunities. Dedicated customers can also join the rewards scheme, where unique perks and customized bonuses are granted for ongoing engagement.
    Notable bonus features include welcome deals, complimentary spins, cashback rewards, and contests featuring
    significant prize pools. After logging in, you will be able to top up your account,
    participate in promotions, track your betting history and manage bonuses.

    The site functions seamlessly across all devices, providing instant page loading and straightforward
    access to games and promotional sections. High rollers are also catered for with special
    monthly bonuses and tailored rewards.

    References:
    https://blackcoin.co/mind-boggling-facts-you-didnt-know-about-online-casino-gaming/

  4. Chrome updates happen in the background automatically — keeping you running smoothly and securely with
    the latest features. No need to manually install or update it –
    with automatic updates, you’ll always get the latest version. If you don’t want Google’s repository, do ‘sudo touch/etc/default/google-chrome’ before installing
    the package. Download Chrome on your mobile device or tablet and sign into your account for
    the same browser experience, everywhere. You can set Chrome as your default browser on Windows or Mac operating systems as well
    as your iPhone, iPad or Android device.
    Here’s a short video giving you some more information about digital banking.

    Change the address and contact details on your account.
    Move your money or make payments to accounts in the UK or overseas.
    Log on with your Secure Key for easy access to your
    accounts.
    Chrome is compatible with devices that run Windows
    and Mac operating systems, provided they meet the
    minimum system requirements. To install Chrome, simply download the installation file, then look for it in your downloads folder.
    Sign in to Chrome on any device to access your bookmarks, saved passwords, and more.
    Open Banking is a secure technology that enables you to share
    your account information with, and make payments through, regulated Third Party Providers.

    For In Person banking, in addition to our branch network,
    you can use the network of Post Office branches to assist with your banking requirements.
    Need to know what banks are close by to Billericay?

    References:
    https://blackcoin.co/stay-casino-no-deposit-bonus-australia-free-spins-bonus-codes-2025/

  5. You can choose to play one of the standard formats for the game, or you
    can try one of these innovative casino variations for a
    new poker experience online. These titles are digital adaptations
    of the popular games that have been played in land casinos for more than centuries now.
    Slots are the most played games in these casinos because of their fast-paced nature,
    exciting gameplay, and rewarding jackpot features.

    It’s the fastest payment method that many Australians
    use for real money gambling on Australian casino sites.
    Sites like King Johnnie and Oshi Casino offer self-exclusion tools and deposit limits to keep your play in check.
    A trustworthy casino displays its license prominently check the footer of sites.
    You won’t get in trouble for playing on these sites, as the law targets
    operators, not players. Most sites let you deposit in AUD$, so you won’t lose
    money on exchange rates. Each type caters to different gaming preferences, payment methods, and player experiences.
    These games add variety but have lower RTPs, so play
    for fun rather than profit.

    References:
    https://blackcoin.co/crown-perth-in-depth-guide/

  6. Players can set deposit limits, loss limits, and wagering limits to manage
    their spending effectively. Our licensing provides a legal framework for Australian residents to participate in online gaming
    activities. We’ve partnered with leading software providers including NetEnt, Microgaming, Evolution Gaming, and Pragmatic Play.

    Overall, Level Up Casino’s strengths, such as its extensive
    game selection, generous bonuses, and mobile-friendly design,
    make it a compelling choice for many Aussie’s players.
    This welcome package allows players to maximize their initial
    bankroll and experience the thrills of the casino’s extensive game library.
    With generous bonuses, lightning-fast payouts, and 24/7 customer support, players of all skill levels can enjoy a secure and rewarding gaming journey.
    Jackpots, bonus buy games, instant games and exclusive games are available to players.

    Each of the accounts of the players of the Level
    Up gambling portal must have a completed verification at the time when the users reach certain stages of
    gaming activity. The Level Up platform has been qualitatively optimised for a comfortable game on mobile devices, and if you have an Android device, you can install a
    special application of this online casino.
    They understand that gambling should always be a fun and entertaining activity, not a source
    of financial or personal problems. The platform employs robust measures to protect your
    personal and financial information. Always check the casino’s terms for the
    most up-to-date information.

    References:
    https://blackcoin.co/mobile-casino/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.