c++ - What would be the correct design approach? -


I have followed the current scenario

I have a validity class in which valid (command *) Function which it validates passed command.

validator {public: validate (command * cmd) {/ / General validation logic}}

I have three sections, WindowsExecute, SolarisExecute and AIXExecute To validate the command before executing Member Function Execution () in SolarisExecute and AIXExecute, create the object directly from the validator and use the valid (comman *) function.

  class SolarisExecute {public: execute (Command * cmd) {Validator v; Valid Valid = v.validate (CMD); // Based on 'valid' some processing}} class AIXExecute {public: execute (Command * cmd) {validator v; Valid Valid = v.validate (CMD); // Some processing on the basis of 'valid'}}  

WindowsExecute is completely different and there is no command in it. Instead it needs to verify some string data. To do this, there is a separate class named as the Windows Videotator, inherited from the vendetta. WindowsExecute :: execute () uses WindowsValidator instead of the verifier.

WindowsValidator: validator {public: valid (const string and xmlData) {// specific validation logic}} class WindowsExecute {public: executed (constring string and data) {WindowsValidate v; Valid Valid = v.validate (data); // Processing on the basis of some 'legitimate'}}

This is the current code

Now I need to do some specific verification of Solaris and therefore Valuerator :: Can not use valid (command *) After the present design, I will need to create a new class named Solaris Validiate and implement my own validation (command *).

I am not comfortable with this approach. I think some issues / comments:

  1. The validator class will be used only by AIXExecute, then why is there a base class, if the remaining argument is not there? Just three sections are SolarisValidator, AIXValidator, WindowsValidator.

  2. Validator :: Valid (command *) unnecessarily inherited in the WindowsValidate class. The signatures of WindowsValidate :: validate and validator :: certified (command *) are different.

  3. I must validate: Valid (command *) Virtual I SolarisValidator :: validate (command *) Introduction This means that I start the upper part of Virtual Points I am, even though I am not using any dynamic polymorphism. So why not go up with # 1 and make three different classes?

What will be the best solution for this scenario, which will be expandable in future also? I am using C ++ for implementation.

Thanks in advance.

-GP

It seems that you have the concept of command, which Is it valid or not? Depending on your platform, the command is displayed in a different form.

So I thought: Why "IIDID" has not created an ICMMand interface with a single function, and make your platform-wrapping code the right identical object that for that platform it will make your "execution" call a validator And will therefore make it platform-independent.

Note: This platform-wrapper subsystem Impo is best designed using a factory pattern.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -