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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:55:37+00:00 2026-05-15T17:55:37+00:00

I am designing a library for my application, that wraps Windows smartcard subsystem. Physically,

  • 0

I am designing a library for my application, that wraps Windows smartcard subsystem.

Physically, there is a smartcard, that is connected to smartcard reader and the reader is connected to PC. There are many types of smartcards (Javacards and .NET cards for example). One idea to design this is as follows:

TReaderListBase <- TReaderListJavaCard

TReaderBase <- TReaderJavaCard

TSmartcardBase <- TJavaCard

List of readers’ Get() method returned reader by index or by name, and the method Connect() of the reader returned the card object instance to work with.

The problem is that while there are physically really different types of smartcards, there is only one reader type actually, that can read them all. TReaderListJavaCard was there only to perform search functions using specific Javacard attributes. And TReaderJavaCard is there only to return an instance of TJavaCard class instead of TSmartcardBase, returned by TReaderBase in Connect() method.

Also this design has some logical holes like, for example, when you plug smartcard out of reader, it may seem logical, that TSmartcardBase descendant instance is immediately destroyed, because class name says, that it impersonates card itself and this card is no more.

Tt works for sure. But does this scheme seem logical?

I had a suggestion from my friend to redesign a system as follows:

Skip readers, create a TSmartcardProxyObjectBase class, descend TJavaCardProxyObject from it and add all methods on searching and connecting cards to them. Something like all-in-one package. This abstraction looks good because indeed CardProxyObject can search for something, connect to something, be offline (if card, to which it is connected is removed) etc. But this design violates SRP because one class does both communication and object searching. Should I want to detach searching functions from it and I get the same scheme as in the first case (it will just add something, that can work with readers).

My friend says, that we do not actually work with readers directly and the main goal of library is to work with cards so we should hide readers from library user.

Since such projects is something you can learn OOP design from, I am interested in finding a crystally beautiful solution 😉

I hope I explained all understandable 😉

There is the third way to do that. Let it be final ReaderList and Reader classes. But there should be no Connect() method in reader. Instead I can implement Use() or PutOnline() method in smartcard class to use this particular reader for communication effectively hiding low-level SCardConnect call from user. Searching functions could be moved into some helper class aside (like TJavaCardLocatorService). Or should I made them static members of TJavaCardProxyObject class? Something like TJavaCardProxyObject.AttachToCardWithAID(ReaderList), but the name looks also illogical and again seem to violate SRP.

What do you think? Is that in any way important to have nice architecture in real life projects or I am just waisting the time trying to learn something unimportant?

  • 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-15T17:55:38+00:00Added an answer on May 15, 2026 at 5:55 pm

    Your friend’s statement is basically on the right track.

    My friend says, that we do not
    actually work with readers directly
    and the main goal of library is to
    work with cards so we should hide
    readers from library user.

    It doesn’t matter if your friend is correct or not; this is exactly what you should be thinking about when you write the abstraction. How will the library user be thinking about the task they’re using the library to accomplish? Figure that out, then implement the abstraction as closely to that as possible.

    Regarding violations of SRP when building an “all-in-one package”, currently the model for programming has the “Programmer” as responsible for not only writing the code, but also compiling, loading, running, and collating the output of the code. It wasn’t that long ago when these secondary tasks were handled by an entirely different person (or possibly multiple people). I’m sure there are some people on SO who remember taking punch cards down to the computer department. Which model violates SRP? Answer: Neither. The concept of what a programmer is responsible for has changed in the last 30 years.

    If you find an model that better fits that changes the concept of single responsibility, that’s okay because the mode is probably a better abstraction for your library users.

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

Sidebar

Related Questions

I am designing a WPF application that uses a DLL with maybe 40 public
For a current project, we're designing a client desktop application that parses text files
I am currently designing a class library that will provide data to a web
I am designing an application for a library. Not a large scale library, but
I'm designing a library that connects to a data source (similar to a DB)
I'm designing a library that will be used to intercept and process incoming messages
I am designing a .Net library that exposes methods all of which can be
I am now designing an SNMP library. The problem is caused by a special
Say you were designing a C++ windowing library. It may or may not provide
Recently I've been designing a Thread class library, I've made a Thread abstract class

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.