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 8675829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:02:29+00:00 2026-06-12T20:02:29+00:00

When setting a property via Dependency Injection (in this case a logging dependancy) is

  • 0

When setting a property via Dependency Injection (in this case a logging dependancy) is it “normal” to make the getter protected so that objects outside of the dependant object cannot call that property?

i.e.

public ILogger Logger { protected get; set; }

vs

public ILogger Logger { get; set; }

(I’m actually using null object pattern in these but that’s beside the point).

I dont want to use constructor injection and yet via public property injection, it’s not “right” for any other object to call this object’s logger.

So above is what im going with but it does seem weird.

  • 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-06-12T20:02:31+00:00Added an answer on June 12, 2026 at 8:02 pm

    Why do you need a getter for the logger at all?

    Objects that you inject should be implementation details of the thing that they are injected into. So in general you should just have a setter for such items.

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

Sidebar

Related Questions

I need to disable IPv6. For that the java documentation indicates setting jvm property
I am trying to change svn:externals property of a remote repository via this command:
This was pretty easy to do in 3.x, simply by setting the autoHeight property
I have a Datagrid, that shows Columns, that are added by setting the ItemsSource-Property
I'm trying to create a simple extensible class in javascript but when setting property
How to enumerate items of Spark List component after setting dataProvider property? I mean
I tried setting the defaultvalue property of the field to Guid.NewGuid() but every item
I'm creating a GroupBox at runtime and setting its Text property. Usually, the text
I am facing problem while setting focus in EdiText. Below is my EditText property.
In a .aspx web page, by setting a textbox's text property by code in

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.