• Sloth Bytes
  • Posts
  • đŸŠ„ When is it "too much" Abstraction

đŸŠ„ When is it "too much" Abstraction

Sponsored by

Hello friends!

Welcome to this week’s Sloth Bytes (late edition 😉 ). I hope you had a chill week 😄 

An AI scheduling assistant that lives up to the hype.

Skej is an AI scheduling assistant that works just like a human. You can CC Skej on any email, and watch it book all your meetings. It also handles scheduling, rescheduling, and event reminders.

Imagine life with a 24/7 assistant who responds so naturally, you’ll forget it’s AI.

  • Smart Scheduling
    Skej handles time zones and can scan booking links

  • Customizable
    Create assistants with their own names and personalities.

  • Flexible
    Connect to multiple calendars and email addresses.

  • Works Everywhere
    Write to Skej on email, text, WhatsApp, and Slack.

Whether you’re scheduling a quick team call or coordinating a sales pitch across the globe, Skej gets it done fast and effortlessly. You’ll never want to schedule a meeting yourself, ever again.

The best part? You can try Skej for free right now.

When is it “too much” Abstraction?

When you first learn about abstraction, you think it’s a great thing.

“Wow simplifying complexity! What could go wrong?”

Well
 a lot.

I’ve learned that abstractions are like makeup.

A little makes everything better, but too much hides what's really happening.

What Are Abstractions?

Abstractions are suppose to hide complexity behind simpler interfaces.

// Raw dogging file reading
const fs = require('fs');
fs.readFile('data.txt', 'utf8', (err, data) => {
    if (err) throw err;
    const lines = data.split('\n');
    console.log(lines);
});


// Abstracted version
const lines = readLines('data.txt');
console.log(lines);

This makes programming easier. Especially when you need to use it in multiple places.

When Does Abstraction Help?

When it eliminates repetition:

// Imagine having to write this every time you wanted to get a user
const user = await new Promise((resolve, reject) => {
    db.get('SELECT * FROM users WHERE id = ?', [id], (err, row) => {
        if (err) reject(err);
        else resolve(row);
    });
});

// With abstraction (Prisma/Drizzle style) Way better...
const user = await db.users.findUnique({ where: { id } });

When Does Abstraction Hurt?

  1. When it becomes a Black Box (you don’t understand what’s happening.)

// Looks simple, but what does "many" mean?
await User.deleteMany({ status: 'inactive' });
  1. Hidden Performance Costs:

// Looks innocent
const sorted = myArray.sort();

// But what sorting algorithm is it using? 
// What if it's bubble sort (O(nÂČ)) instead of quicksort (O(n log n))?

The Sweet Spot

  1. Good Abstractions Are “Leaky.” You can still access the details:

try {
    const response = await axios.get('/users');
    return response.data;
} catch (error) {
    // Can access details when needed
    if (error.response.status === 429) { 
    }
}
  1. They handle easy common case and possible hard case:

// Simple
const data = await http.get('/users'); 

// Full control available just in case
const full_data = await http.request({
    method: 'GET',
    url: '/users',
    timeout: 5000, 
    retries: 3
});

Guidelines For Abstraction

  1. Start concrete, then abstract - Extract patterns after seeing them

  2. Hide complexity that doesn't matter - Expose details users might need

  3. Test without the abstraction - Maybe you don’t need it in the first place

Red Flags

  • Can't debug because abstraction hides too much

  • Fighting the abstraction to do unintended things

  • Don't understand what it does but it "just works"

The Bottom Line

Use abstractions to eliminate repetition and make complex things approachable. Don't let them hide important details.

Ask yourself:

"Does this make my code simpler without making debugging harder?"

Good abstractions feel invisible when working, but also transparent when broken.

Thanks for the feedback!

Thanks to everyone who submitted!

Vowel Skewers

An authentic vowel skewer is a skewer with a delicious and juicy mix of consonants and vowels. However, the way they are made must be just right:

  • Skewers must begin and end with a consonant.

  • Skewers must alternate between consonants and vowels.

  • There must be an even spacing between each letter on the skewer, so that there is a consistent flavour throughout.

Create a function which returns whether a given vowel skewer is authentic.

Examples

is_authentic_skewer("B--A--N--A--N--A--S")
output = True

is_authentic_skewer("A--X--E")
output = False
# Should start and end with a consonant.

is_authentic_skewer("C-L-A-P")
output = False
# Should alternate between consonants and vowels.

is_authentic_skewer("M--A---T-E-S")
output = False
# Should have consistent spacing between letters.

Notes

  • All letters will be given in uppercase.

  • Strings without any actual skewer "-" or letters should return False.

How To Submit Answers

Reply with

  • A link to your solution (github, twitter, personal blog, portfolio, replit, etc)

  • or if you’re on the web version leave a comment!

  • If you want to be mentioned here, I’d prefer if you sent a GitHub link or Replit!

That’s all from me!

Have a great week, be safe, make good choices, and have fun coding.

If I made a mistake or you have any questions, feel free to comment below or reply to the email!

See you all next week.

What'd you think of today's email?

Login or Subscribe to participate in polls.

Want to advertise in Sloth Bytes?

If your company is interested in reaching an audience of developers and programming enthusiasts, you may want to advertise with us here.

Reply

or to participate.