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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:34:32+00:00 2026-05-14T05:34:32+00:00

Naming classes is sometimes hard. What do you think name of the class should

  • 0

Naming classes is sometimes hard. What do you think name of the class should be?

I originally created the class to use as a cache but can see its may have other uses. Example code to use the class.

Dim cache = New NamePendingDictionary(Of String, Sample)

Dim value = cache("a", Function() New Sample())

And here is the class that needs a name.

' <summary> '
' Enhancement of <see cref="System.Collections.Generic.Dictionary"/>. See the Item property '
' for more details. '
' </summary> '
' <typeparam name="TKey">The type of the keys in the dictionary.</typeparam> '
' <typeparam name="TValue">The type of the values in the dictionary.</typeparam> '
Public Class NamePendingDictionary(Of TKey, TValue)
    Inherits Dictionary(Of TKey, TValue)

    Delegate Function DefaultValue() As TValue

    ' <summary> '
    ' Gets or sets the value associated with the specified key. If the specified key does not exist '
    ' then <paramref name="createDefaultValue"/> is invoked and added to the dictionary. The created '
    ' value is then returned. '
    ' </summary> '
    ' <param name="key">The key of the value to get.</param> '
    ' <param name="createDefaultValue"> '
    ' The delegate to invoke if <paramref name="key"/> does not exist in the dictionary. '
    ' </param> '
    ' <exception cref="T:System.ArgumentNullException"><paramref name="key" /> is null.</exception> '
    Default Public Overloads ReadOnly Property Item(ByVal key As TKey, ByVal createDefaultValue As DefaultValue) As TValue
        Get

            Dim value As TValue

            If createDefaultValue Is Nothing Then
                Throw New ArgumentNullException("createValue")
            End If

            If Not Me.TryGetValue(key, value) Then

                value = createDefaultValue.Invoke()
                Me.Add(key, value)

            End If

            Return value

        End Get

    End Property

End Class

EDIT: On Abel’s advice I’ve named the class ValueCache.

  • 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-14T05:34:32+00:00Added an answer on May 14, 2026 at 5:34 am

    In general, it’s best to name a class after its intended usages. If users later find that another usage is possible or feasible, don’t run off renaming your class. A reason to rename your class should only be to make its intended use clearer.

    (edit) Others have commented on new names, like CacheManager, DeferredCache, LazyCollection, AssignedValueMap etc. If the original intention is very generic, use such names. If the intended use is more specific, name it such: CookiesCache, UsersList etc.

    If you find yourself in the situation where you have a generic use case for an otherwise specific class, create a more general base class, with a general name, and use a specific subclass for the specific (original) use case. That’s what OO is about 😉

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

Sidebar

Related Questions

I have 2 classes with the same name but in different namespaces. I can't
The standard naming convention in the Java world is to name packages, classes and
In .NET, Microsoft has guidelines for naming classes, members, etc. when developing class libraries.
I tend to have this redundant naming in case classes: abstract class MyTree case
When naming classes and IDs for CSS what is the best method to use.
Is there a standard way I should be naming my element's IDs and classes.
I can't figure out what is the more acceptable naming convention for derived classes.
Following Alan Green's Naming Java classes without Manager I've started hunting *Manager classes in
What is the recommended approach to naming base classes? Is it prefixing the type
I am building a CMS and the naming convention for classes has been debated

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.