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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:22:21+00:00 2026-06-14T13:22:21+00:00

I have an interface Serializable . This class have methods for each Item subclass

  • 0

I have an interface Serializable. This class have methods for each Item subclass in my application. However not all classes that implements Serializable have a reasonable implementation of the serialize method. Some of the serializers should not be able to serialize all the different objects because of security constraints in my application.

How should I solve this? Should I serialize a message that says “Serializer can’t serialize object because of security constraints.” or should I throw an RuntimeException? Or are there other ways of “fixing” this?

  • 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-06-14T13:22:22+00:00Added an answer on June 14, 2026 at 1:22 pm

    You would violate one important principle with your logic: Interface Segregation Principle

    The Interface Segregation Principle states that clients should not be
    forced to implement interfaces they don’t use. Instead of one fat
    interface many small interfaces are preferred based on groups of
    methods, each one serving one submodule.

    So, I would create two distinct base classes to achieve your requirement:

    • Item
    • SerializableItem

    And your visitor would only rely on SerializableItem objects:

    public void visit(SerializableItem sItem) 
    

    Of course, it is possible to gather only common behaviour (unrelated to serialization so) of both classes within a kind of AbstractItem, as long as the visitor doesn’t deal with it.

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

Sidebar

Related Questions

If a Java class implements the Serializable interface but does not have a public
I have a class Data which implements Serializable interface. This class has such fields
I have an Interface as Contract. Now I'd like to define all Classes implementing
I have this interface: public interface IDbTable extends Serializable { public int getId(); }
Reflexion API shows that any Java array class implements interface java.lang.Cloneable and java.io.Serializable. It
I have a simple RMI 'compute' server application (similar to this ) that accepts
I have interface IConfigurationSource { .... } and class FileConfigurationSource : IConfigurationSource { FileConfigurationSource(string
I have interface Foo public interface Foo { public void test(); } Class FooChild
Let's say we have interface window_creator that responsible for creation of windows. For simplicity
I'm trying to figure out why this code won't compile. I have interface A

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.