Member-only story
GitHub Copilot : Inversing the Logic design
To communicate your software system to other developers, users, and stakeholders logic design and flowchart are one of the best medium. Logic design helps defining the inputs, outputs , functions and condition of a software system where flowchart acts as a graphical tool to represent a software system using symbols and connectors.
Lets now see how copilot can create logic design from a given code and help us generate a flowchart :
Sample Code
void SocketServer::_initServerSockets(const std::set<uint16_t> &ports)
{
sockaddr_in m_address;
std::memset(&m_address, 0, sizeof(m_address));
m_address.sin_family = AF_INET; // AF_INET is the Internet address family for IPv4.
m_address.sin_addr.s_addr = INADDR_ANY; // INADDR_ANY -> binds the socket to all available interfaces(e.g. wifi, ethernet, etc.)
std::set<uint16_t>::iterator it = ports.begin();
for (; it != ports.end(); it++)
{
m_address.sin_port = htons(*it); // htons() -> For transforming uniform byte order.
std::pair<std::set<int>::iterator, bool> socketSetRet;
socketSetRet = _serverSockets.insert(socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0)); //TODO: maybe add close on exec
if (*(socketSetRet.first) == -1)
throw std::runtime_error("Socket creation failed");
if (bind(*(socketSetRet.first), (struct sockaddr *)&m_address…






