c++ - Apply a Bridge pattern to an existing class design -


no bridge

can see have interface debug events , 2 operations attach , detach. on top of have implement windows , linux version current design not scale @ all.

imagine have add:

  • debugeventthread <- debugeventthreadattach <- debugeventthreaddetach
  • debugeventprocess <- debugeventprocessattach <- debugeventprocessdetach

this design blows out of proportions...

i know bridge pattern solution problem how applied in case?

update: first fix i'm thinking of adding member operation (attach/detach) debugeventmodule. way no more subclass needed different type of attach/detach operations:

1.
bridge
bridge between debugeventmodule -> debugeventmoduleimpl seems useless me @ point, can see benefit of having bridge here? without bridge have:

2.
inheritance
moving platform specific stuff (os stuff) out of way bridge? this:

3.
platform abstraction
i'm thinking in last design platform_specific() functions module, thread, process specific , goes against "one responsibility principal", wouldn't want class become "mammoth", become combination of unrelated functions.

update 2: current implementation debugevent + debugeventmodule:

    class debugevent {     public:       debugevent(uint32_t processid,                  uint32_t threadid);       virtual ~debugevent();       virtual void process() = 0;     private:       uint32_t _processid;       uint32_t _threadid;     };      class debugeventmodule : public debugevent {     public:       debugeventmodule (uint32_t processid,                         uint32_t threadid,                         handle_t filehandle,                         hmodule_t baseofdll,                         address_t imagename,                         uint16_t isunicode);       virtual ~debugeventmodule();       virtual void process();     private:       handle_t _filehandle;       hmodule_t _baseofdll;       address_t _imagename;       uint16_t _isunicode;     };      class debugeventmoduleattach : public debugeventmodule {};     class debugeventmoduledetach : public debugeventmodule {};      class debugeventmoduleattachwindows : public debugeventmoduleattach {};     class debugeventmoduleattachlinux : public debugeventmoduleattach {};      class debugeventmoduledetachwindows : public debugeventmoduledetach {};     class debugeventmoduledetachlinux : public debugeventmoduledetach {}; 


idea make platform independent version of windows debug_event: https://msdn.microsoft.com/en-us/library/windows/desktop/ms679308%28v=vs.85%29.aspx

windows debug_event looks this:

    typedef struct _debug_event {       dword dwdebugeventcode;       dword dwprocessid;       dword dwthreadid;       union {         exception_debug_info      exception;         create_thread_debug_info  createthread;         create_process_debug_info createprocessinfo;         exit_thread_debug_info    exitthread;         exit_process_debug_info   exitprocess;         load_dll_debug_info       loaddll; // - debugeventmoduleattach in original design         unload_dll_debug_info     unloaddll; // - debugeventmoduledetach in original design         output_debug_string_info  debugstring;         rip_info                  ripinfo;       } u;     } debug_event, *lpdebug_event; 


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -