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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:58:08+00:00 2026-05-20T08:58:08+00:00

So after some experimenting I was surprised to find that this is perfectly acceptable,

  • 0

So after some experimenting I was surprised to find that this is perfectly acceptable, in the sense that MVC does not complain about my protected inner abstract Metadata class, and the model validation still works:

Partial Domain Object, generated by a tool:

Partial Public Class SampleDomainObject

    Private _id As Integer
    Private _customCode As String
    Private _description As String

    Public Property ID() As Integer
        Get
            Return Me._id
        End Get
        Set(ByVal value As Integer)
            Me._id = value
        End Set
    End Property

    Public Property CustomCode() As String
        Get
            Return Me._customCode
        End Get
        Set(ByVal value As String)
            Me._customCode = value
        End Set
    End Property

    Public Property Description() As String
        Get
            Return Me._description
        End Get
        Set(ByVal value As String)
            Me._description = value
        End Set
    End Property

End Class

Partial Domain Object, metadata implementation

<MetadataType(GetType(SampleDomainObject.Metadata))> _
Partial Public Class SampleDomainObject

    Protected Friend MustInherit Class Metadata

        <HiddenInput()> _
        Public MustOverride Property ID() As Object

        <Required(), _
        StringLengthRange(4), _
        DisplayName("Custom Code")> _
        Public MustOverride Property CustomCode() As Object

        <Required(), _
        StringLength(255)> _
        Public MustOverride Property Description() As Object

    End Class

End Class

I did this because I didn’t want to have to implement actual properties with backing fields, getters, and setters in VB.NET for the Metadata class to keep the maintenance to a minimum (I’m on .NET 3.5, no auto-properties for me).

What I’m worried about is that having a protected abstract inner class could be confusing to others using this domain object outside of MVC (my domain objects are part of a shared data access framework).

So my question is, in the world of MVC best practices, is this acceptable? Clever even? I’m an MVC newcomer, so I’ll take any feedback I can get.

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-20T08:58:08+00:00Added an answer on May 20, 2026 at 8:58 am

    In Silverlight applications using RIA services, the metadata classes look very similar, minus the MustInherit. I suspect your practices follow suitably good practices, even outside of the context of MVC, considering that the behavior can be seen with MVC and domain services.

    I asked a related question yesterday. The answer describes how this kind of a buddy class strategy works effectively in situations where the domain classes are code-generated. Buddy classes provide protection against code-gen-overwrites. (See Why are buddy classes used for validation?.)

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

Sidebar

Related Questions

After doing some research on the subject, I've been experimenting a lot with patterns
I am, for some time, experimenting with LLVM , simply because. It does, however,
So I'm doing some experimenting with PHP/Apache. Let's say I have this code. <div>DIV
After experimenting with some triangulation work I ran across the question on how to
So I'm experimenting in pygame and wrote some code for a rectangle that slowly
after some days of experimenting with Protocol Buffers I tried to compress the files.
after some experimenting, I have been able to inject my GET-parameters into an @ManagedBean
After some time researching and trying different things I still cannot get my @ExceptionHandler
After some desperate assistance regarding prototype.js on Magento. Please see the below product page
After some great help from Josh Mein with a Javascript Hide/Show menu, the menu

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.