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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:22:54+00:00 2026-06-08T12:22:54+00:00

Im trying to improve my code structure so perhaps i could get some input

  • 0

Im trying to improve my code structure so perhaps i could get some input on the following points and questions regarding how to handle primarily services.

  1. A service should not be dependent on the presentation layer, so passing stuff like httpcontext into service / service functions through constructor and similar is a bad practice, correct?

  2. Should one not have services referencing each other? Should they only work ‘downward’ like for example repository dependency? Or that is considered ok?

  3. Would a service only contain functionality directly related to filtering and processing information from the database / repository or could one consider for example a class dedicated purely to encryption and generating random strings / passwords or a class handling provider relying party functionality a service as well? Or they / one would be considered utility classes perhaps?

  4. Is there a good and accepted way to manipulate sessions inside a service or this should be passed to the controller and handled there?

  • 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-08T12:22:55+00:00Added an answer on June 8, 2026 at 12:22 pm

    A service should not be dependent on the presentation layer, so
    passing stuff like httpcontext into service / service functions
    through contstructor and similar is a bad practise, correct

    If you can avoid it, avoid it. But it depends, if its a service for the presentation layer, then it can be OK.

    Should one not have services referencing each other? Should they only
    work ‘downward’ like for example repository dependancy? Or that is
    considered ok?

    If you can avoid it, avoid it. It dependes on you architecture, if, for example, your are working in asp.net mvc, you would do well in avoiding this, and keeping the kind of code that orchestrates your multiple service at the Controller level

    Would a service only contain functionality directly related to
    filtering and processing information from the database / repository or
    could one consider for example a class dedicated purely to encryption
    and generating random strings / passwords or a class handling provider
    relying party functionality a service as well? Or they / one would be
    considered utility classes perhaps?

    You can use services for filtering and processing information from the database / repository or you can also create one dedicated purely to encryption and generating random strings / passwords. Services are classes, so it is important that they follow the Single Responsability Principle

    Is there a good and accepted way to manipulate sessions inside a
    service or this should be passed to the controller and handled there?

    It is better for scaling if your services are stateless, but if you are going to have to deal with sessions or other lifecycle stuff, and you are building web systems in .net, the best you could do is to use asp.net mvc, integrated with Unity so that you get Inversion Of Control, that way you can deal with session using life time managers

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

Sidebar

Related Questions

I am trying to improve some code and I can't think of a better
I'm trying to improve some existing code which originally took 3 minutes to prepare
I'm trying to introduce some tools at work to improve code quality. An obvious
I'm trying to improve the speed of some code I've written. I was wondering
I'm trying to improve FxCop compliance in my code (for the first time ever),
I have been recently going through my database code trying to improve on my
So I'm on commission for a website, and I'm trying to improve my code.
OK, I'm always trying to improve the way I code, because it's my passion.
I'm trying to condense/improve/optimize this code cleaned = stringwithslashes cleaned = cleaned.replace(\\n, \n) cleaned
I am trying to improve an existing javascript levenstein distance calculation source code to

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.