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

  • SEARCH
  • Home
  • 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 7086239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:31:30+00:00 2026-05-28T07:31:30+00:00

In the Head First Design Patterns book, the author often says that one should

  • 0

In the Head First Design Patterns book, the author often says that one should program to interface rather than implementation?

What does that mean?

  • 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-28T07:31:30+00:00Added an answer on May 28, 2026 at 7:31 am

    Let’s illustrate it with the following code:

    namespace ExperimentConsoleApp
    {
        class Program
        {
            static void Main()
            {
                ILogger loggerA = new DatabaseLogger();
    
                ILogger loggerB = new FileLogger();
    
                loggerA.Log("My message");
                loggerB.Log("My message");
            }
        }
    
        public interface ILogger
        {
            void Log(string message);
        }
    
        public class DatabaseLogger : ILogger
        {
            public void Log(string message)
            {
                // Log to database
            }
        }
    
        public class FileLogger : ILogger
        {
            public void Log(string message)
            {
                // Log to File
            }
        }
    
    }
    

    Suppose you are the Logger developer and the application developer needs a Logger from you. You give the Application developer your ILogger interface and you say to him he can use but he doesn’t have to worry about the implementation details.

    After that you start developing a FileLogger and Databaselogger and you make sure they follow the interface that you gave to the Application developer.

    The Application developer is now developing against an interface, not an implementation. He doesn’t know or care how the class is implemented. He only knows the interface. This promotes less coupling in code and it gives you the ability to (trough configuration files for example) easily switch to another implementation.

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

Sidebar

Related Questions

After reading the Head First Design Patterns book and using a number of other
I'm reading through head first design patterns at the moment and while the book
Today I got my book Head First Design Patterns in the mail. Pretty interesting
I came across this example in Head First Design Patterns book. Pizza class has
After reading the most excellent book Head First Design Patterns, I began proselytizing to
I'm currently reading Head First's Object Oriented Analysis and Design. The book states that
The references (GOF Design Patterns, Head First Design Patterns, http://www.dofactory.com/Patterns/PatternObserver.aspx ) that I've read
From Head First design patterns book, the singleton pattern with double checked locking has
I recently read the Head First Design Patterns book and I especially liked how
Having recently discovered design patterns, and having acquired the excellent Head First Design Patterns

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.