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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:58:42+00:00 2026-05-18T11:58:42+00:00

I started designing a small application and have some architecture-related questions. I have some

  • 0

I started designing a small application and have some architecture-related questions.

I have some basic entities, which I’m willing to model – Repository and Indicator.

Repository is basically a facade using the Repository Pattern, which is able to retrieve / store arbitrary entities using some database holder (right now it’s NHibernate-driven, but I guess that’s not actually important).

The Indicator may be called the logical core of my application. It is used to combine abstract values and the exact time at which that value was achieved (so it forms and operates on Value - Time pairs).

I am willing to make this Indicator as generic as possible, still I think my current solution is a big fail 🙂

See the following chunks of code:

public interface IIndicator<T>
{
    IEnumerable<T> RetrieveValues(DateTime start, DateTime end);
}

// Should also have something like indicator wrapper / proxy stub here - anything
// that represents the 'IIndicator' interface acts through that proxy and
// caches the evaluated data using it.

This is a basic attempt to implement the indicator (right now this can actually be considered as a mock):

public class Indicator<TValue> :
    // Self-referencing generic parameter.
    IIndicator<Indicator<TValue>.TimestampProxy>
{
    // Proxy, which is used to add the timestamp to
    // every indicated value.
    public class TimestampProxy
    {
        public TValue Value;
        public DateTime Time;

        public TimestampProxy(DateTime time, TValue value)
        {
            Time = time;
            Value = value;
        }
    }

    private readonly IRepository repository;

    public Indicator(IRepository repository)
    {
        this.repository = repository;
    }

    public IEnumerable<TimestampProxy> RetrieveValues(DateTime start, DateTime end)
    {
        // Note the custom time stamp comparation in the lambda
        // expression. Comparation includes the 'start' and 'end' limits.
        IQueryable<TimestampProxy> queryable = repository.Retrieve<TimestampProxy>(
            x => x.Time.CompareTo(start) >= 0 && x.Time.CompareTo(end) <= 0);

        return queryable.ToList();
    }
}

Now – this might look fine, but I’m absolutely sure that the TimestampProxy used is really evil.

It also makes the things hard to understand (for example, method signature IEnumerable<TimestampProxy> RetrieveValues(...) would probably result in a “wtf?!” phrase from a person who examines the code).

Unfortunately, I can’t come up with a better solution / global redesign – could you advice me how to do it or simply tell some ideas about how this kind of feature should be done?

Thanks.

  • 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-18T11:58:43+00:00Added an answer on May 18, 2026 at 11:58 am

    How about refactoring the RetrieveValues method back into the Repository itself and going with a much simpler Indicator class that basically replaces your TimestampProxy class.

    public class Indicator<T>
    {
         public DateTime Timestamp { get; set; }
         public T Value { get; set; }
    }
    
    
    public class Repository
    {
    
         public IEnumerable<Indicator<T>> RetrieveIndicators<T>( DateTime start, DateTime end )
         {
              // determine table to query based on type T
              // query and convert objects to Indicator<T>
              // return collection
         }
    }
    

    One thing that bothers me is that in making it generic you’ve lost the connection to the DB table. It might be better to simply define an interface that all of your specific DB objects implement and use partial implementations to map the actual “value” onto the Value property.

    public interface Indicator<T>
    {
         DateTime Timestamp { get; }
         T Value { get; }
    }
    
    public partial class TemperatureIndicator : Indicator<double>
    {
         public double Value { get { return this.Temperature; } }
    }
    

    Now have your repository implement methods that return objects of each type — which can be used as (in .NET 4 or cast to in lower versions) objects of the interface type for common operations.

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

Sidebar

Related Questions

Just started designing a database which I have not done before. And am wondering
i need some help with designing iphone's core data object model context. I've started
I started java this summer and am designing a small game in my free
I have started design of a ColdFusion application that is entirely web based. Not
I have this task of designing a new interface for a distributed application (multiple
At work, we've recently started designing an application to me large scale (we're engineering
I have just started playing with storyboards in XCode 4.3 and while designing an
How do I get started designing and implementing a script interface for my .NET
Just today I've started using Drupal for a site I'm designing/developing. For my own
Started working on a new application this week that is running the latest rails

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.