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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:33:41+00:00 2026-05-26T16:33:41+00:00

I have a studentadministration application. Now I have to implement a new part of

  • 0

I have a studentadministration application. Now I have to implement a new part of this application that gives advise (in the style of a text) depending on the grades of the student. So we have 1 “algorithm” and 4(for the moment) different texts(variations) as output).

What is the best pattern in this case?
I personally think about using the bridge pattern so that I can put the algorithm in the abstraction class and put the different texts as concrete implementors.

  • 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-26T16:33:41+00:00Added an answer on May 26, 2026 at 4:33 pm

    I think you’re over engineering this.

    This is a pretty simple search algorithm problem. Your domain consists of Students (who want advice), Pieces of Advice (who contain knowledge), and a Provider of some kind, which will contain a search algorithm to help the student find advice.

    Using the following, I can simply change the search algorithm at any time to suit my needs. I can either create an entirely new search, or modify the one I already have. In addition, I could create a search that works off of a database instead of a list of advice. I can add new criteria by updating my StudentAdvice model and searching for that advice within the provider (these are two distinct changes, so it does not violate the Open/Closed principle).

    class Program
    {
        static void Main(string[] args)
        {
            var advices = new[]
            {
                new StudentAdvice{ Grade = 60, Advice = "Talk to your professor." },
                new StudentAdvice{ Grade = 70, Advice = "Spend more time studing." },
                new StudentAdvice{ Grade = 80, Advice = "Spend even more time studing." },
                new StudentAdvice{ Grade = 90, Advice = "You're doing great, almost there!" },
                new StudentAdvice{ Grade = 100, Advice = "Perfect!" },
            };
    
            IStudentAdviceProvider adviceProvider = new GradeBasedAdviceProvider(advices);
    
            var student = new Student { Name = "Jim", Grade = 80 };
    
            foreach(var advice in adviceProvider.GetAdvice(student))
            {
                Console.WriteLine(advice.Advice);
            }
        }
    }
    
    public interface IStudentAdviceProvider
    {
        IEnumerable<StudentAdvice> GetAdvice(Student student);
    }
    
    public class GradeBasedAdviceProvider : IStudentAdviceProvider
    {
        private readonly IEnumerable<StudentAdvice> advices;
    
        public GradeBasedAdviceProvider(IEnumerable<StudentAdvice> advices)
        {
            this.advices = advices;
        }
    
        public IEnumerable<StudentAdvice> GetAdvice(Student student)
        {
            // Advice Selection Algorithm
            return advices.Where(advice => student.Grade <= advice.Grade).Take(1).ToList();
        }
    }
    
    public class Student
    {
        public string Name { get; set; }
        public int Grade { get; set; }
    }
    
    public class StudentAdvice
    {
        public int Grade { get; set; }
        public string Advice { get; set; }
    }
    

    At it’s core, this could be used as a strategy pattern. However, I started with the domain, and the pattern emerged itself. Picking patterns first codes you into corners.

    Learning design patterns gives us a bunch of tools to use. Learning SOLID design principles allows us to realize when those tools should be used. The following site has some great resources related to OOD.

    http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod

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

Sidebar

Related Questions

Have converted devise new session from erb to Haml but doens't work, this is
Have have this line of code in my form when I create a new
Have some dates in my local Oracle 11g database that are in this format:
Have an app that can use tts to read text messages. It can also
Have seen that this piece of code could solve my problems but I don't
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
Have a n-tire web application and search often times out after 30 secs. How
Have you managed to get Aptana Studio debugging to work? I tried following this,
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:

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.