Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 557079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:59:16+00:00 2026-05-13T11:59:16+00:00

I was reading up some things about how to design a library or API

  • 0

I was reading up some things about how to design a library or API well, and stumbled across Joshua Bloch’s great talk at Google Tech Talks. Now although I am nowhere near a professional API developer, I think programming a bunch of classes/functions is a similar, although much scaled-down version of the same thing – clear-cut separation of actions, ease and pleasurable use, encouraging clean code, etc.

I was going through some widely used open source Java code and got this idea (nothing new, but just putting it up lucidly…)

Let us take an example pseudo code (or maybe some dialect of BASIC):

1. new label
2. set name 'hello world'
3. set color 'blue'
4. show 'topmost'
5. on click hide

Now inspired by the Java code I would want to be able to do something like this:

1. Label l = new Label()
2.          .setName('Hello World')
3.          .setColor('blue')
4.          .show(zindex.top);
5. l.onClick = l.hide() ;

My question is this:
Does anyone else design APIs starting from pseudo-code like this?

Is it a good idea for something small? Say upto 10 classes each with maybe 10 methods, each method not more than than 5-6 lines code inside it. That is obviously just a rough set of numbers to to show the size of the classes to be designed – nowhere close to a full API and not just a hobby project – a professional package that does something small but does it well.

Has anyone found any serious drawbacks to this approach?

I think the one real benefit is that it forces you to write down your use-cases first.

The other thing is that the nouns and verbs stay simple, enabling your final product to dodge the MultiPhraseAbstractParadigmDesignPatternImplementor syndrome 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:59:16+00:00Added an answer on May 13, 2026 at 11:59 am

    This is a fairly common design pattern called a fluent interface. It’s common in functional languages and is gaining popularity elsewhere. I first saw it in Scheme.

    It’s a very convenient and readable idiom, but remember that there will often be times where you actually do want to initialize more than one variable in a single function call. For example, when there’s internal state that has to be set depending on a combination of data, or when setting and overwriting default values is costly. So, as with all “patterns”, use judiciously and with forethought.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 300k
  • Answers 300k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You want the svn status command. svn status # By… May 13, 2026 at 8:04 pm
  • Editorial Team
    Editorial Team added an answer Unfortunately, there isn't an easy way to import/export categories. I'm… May 13, 2026 at 8:04 pm
  • Editorial Team
    Editorial Team added an answer It seems hacky, but unless somebody can come up with… May 13, 2026 at 8:04 pm

Related Questions

I have a project that I have been working on for a while, just
I'm trying to write some STL data out of matlab and I'm trying to
Recently, I've been reading up on the IRC protocol (RFCs 1459, 2810-2813), and I
I am just learning about escaping things and started reading about how it could
I've been reading about dependency injection and have a simple question. I can understand

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.