Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Good practice?
Forum Updated to NodeBB v4.3 + New Features

Good practice?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lunatic
    wrote on last edited by
    #1

    If I want to create a class called Receiver which should listen on a port and work with the incoming messages, should I derive it from Q***Socket or should I give the class an attribute ?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      Immii
      wrote on last edited by
      #2

      It is not mandatory to derive from socket class IMO

      It all depends up on you. You may have an object of your TCP class in side your own separate listener class or you can listen in the TCP class itself and then do the processing in some other thread

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        I would go for the composition pattern (socket as attribute in the class). You seem to not want to change the socket's behaviour or add some functionality to it (what would be an indicator for using inheritance). It's the same as with a QTextEdit - if you just use it, you will not inherit it, but use it as an attribute :-)

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved