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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:49:33+00:00 2026-05-18T04:49:33+00:00

I am new to design patterns. I am looking for a pattern similar to

  • 0

I am new to design patterns. I am looking for a pattern similar to the factory pattern but that will also let me “set” the product. Something like this:

class VehicleFactory
{
    IVehicle static GetVehicle();
    void static SetVehicle(IVehicle vehicle);
}

Is there any known pattern similar to this? Thank you.

EDIT: I am looking to store “POCO” objects in the Session object and use a class to set/ get them. I may want to switch persistance to ViewState/ database in the future. This is what I have:

// object to persist in Session.
class Vehicle
{
    string Make { get; set; }
    string Model { get; set; }
}

// class to set/ get object from Session.
// Please see VehicleFactory above.
  • 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-18T04:49:33+00:00Added an answer on May 18, 2026 at 4:49 am

    Factory pattern is a creational design pattern with encapsulates the creation of a complex object and isolates the creation process from your business logic.

    Here it looks like you want a cache to store and manage the Vehicle instances. I would recommend that you call this class a VehicleCache rather than Factory and implement like a cache.

    Firstly you should consider having and identifier for the Vehicle object like a vehicleId. I would also recommend that you implement it as an entity object as described in Domain Driven Design.

    Then you can implement your cache like this –

    public class VehicleCache
    {
        public void Add(IVehicle instanceToAdd)
        {
        // Store instance in session object
        }
    
        public IVehicle Get(string id) 
        {
         // search and return vehicle from cache
        }
    
        // more methods and indexer if required
    }
    

    Here are some links that explain how you can implement such cache for your application in a thread safe fashion –

    https://blogs.infosupport.com/blogs/frankb/archive/2008/12/31/Implementing-a-Thread-Safe-cache-using-the-Parallel-Extensions.aspx

    http://www.objectreference.net/post/Implementing-Generic-Caching.aspx

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

Sidebar

Related Questions

I have been looking at the decorator design pattern (I am new to the
I'm looking for design patterns (GOF, but others would be welcome too) for Delphi
I'm new in Design Patterns so I have one question about the Builder Pattern.
We're working now on the design of a new API for our product, which
Is there a way to define a macro (or something similar) that would allow
Am new to design patterns, could you recommend a open code base (preferably in
I'm looking for help identifying this design pattern and learning the typical vocabulary it
is there any new design patterns available other than the patterns covered by GoF
I'm kind of new to the design patterns concept. C# is my primary programming
Im new in OOP programming and C++ and Im currently into learning 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.