Click here to Skip to main content
15,888,176 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: Would it be possible to build megastructures like the Forerunners in <i>Halo</i>? Pin
jschell30-Dec-21 7:50
jschell30-Dec-21 7:50 
GeneralRe: Would it be possible to build megastructures like the Forerunners in <i>Halo</i>? Pin
Dave Kreskowiak30-Dec-21 8:01
mveDave Kreskowiak30-Dec-21 8:01 
GeneralRe: Would it be possible to build megastructures like the Forerunners in <i>Halo</i>? Pin
jschell30-Dec-21 8:12
jschell30-Dec-21 8:12 
GeneralRe: Would it be possible to build megastructures like the Forerunners in <i>Halo</i>? Pin
oofalladeez34330-Dec-21 7:44
professionaloofalladeez34330-Dec-21 7:44 
GeneralRe: Would it be possible to build megastructures like the Forerunners in <i>Halo</i>? Pin
oofalladeez34330-Dec-21 7:44
professionaloofalladeez34330-Dec-21 7:44 
GeneralRe: Would it be possible to build megastructures like the Forerunners in <i>Halo</i>? Pin
MarkTJohnson25-Feb-22 8:40
professionalMarkTJohnson25-Feb-22 8:40 
JokeRe: Would it be possible to build megastructures like the Forerunners in <i>Halo</i>? Pin
englebart15-Feb-22 17:00
professionalenglebart15-Feb-22 17:00 
AnswerRe: Would it be possible to build megastructures like the Forerunners in <i>Halo</i>? Pin
jschell30-Dec-21 7:42
jschell30-Dec-21 7:42 
Questionquantum computing Pin
Calin Negru28-Dec-21 7:13
Calin Negru28-Dec-21 7:13 
AnswerRe: quantum computing Pin
Gerry Schmitz28-Dec-21 7:25
mveGerry Schmitz28-Dec-21 7:25 
GeneralRe: quantum computing Pin
Calin Negru2-Jan-22 2:48
Calin Negru2-Jan-22 2:48 
AnswerRe: quantum computing Pin
Member 155103601-Feb-22 1:41
Member 155103601-Feb-22 1:41 
QuestionRefactoring a Slow UI Pin
Kevin Marois21-Dec-21 9:01
professionalKevin Marois21-Dec-21 9:01 
AnswerRe: Refactoring a Slow UI Pin
englebart15-Feb-22 17:21
professionalenglebart15-Feb-22 17:21 
Question[Solved] Opinions on two code layout alternatives? Pin
RobertSF10-Dec-21 10:43
professionalRobertSF10-Dec-21 10:43 
I have an application that reads a directory's files, displays them in a grid, and offers a toolbar with buttons that invoke functions that apply to all the files in the grid.

In the following code, reduced to its essentials, when the user clicks the Trim button in the toolbar, toolTrim_Click executes, opening the form that collects the options for the Trim operation, and then invoking the method that trims the pages from the list of files. That method then invokes for each file the method that trims the pages from that particular file. The async part is just to keep the window draggable.
C#
//Main Form:
private async void toolTrim_Click(object sender, EventArgs e)
{
    var form = new TrimOptions();
    DialogResult result = form.ShowDialog();
    if (result == DialogResult.OK)
    {
        await Task.Run(() => filesList.TrimPages(form.trimFirst, form.trimLast, form.ifBlank));
    }
    form.Dispose();
}

//filesList Class:
public void TrimPages(bool trimFirst, bool trimLast, bool ifBlank)
{
    for (int entry = 0; entry < TotalPDFs; entry++)
    {
        FileEntry thisFile = list[entry];
        thisFile.Trim(trimFirst, trimLast, ifBlank);
    }
}

//thisFile Class:
public void Trim(bool front, bool back, bool ifBlank)
{
    // code
}
What would be the pros and cons of refactoring the above code like this? The difference is that we move opening the options form to the class that manages the list of files instead of keeping it in the main form class.
C#
//Main Form:
private async void toolTrim_Click(object sender, EventArgs e)
{
    await Task.Run(() => filesList.TrimPages());
}

//filesList Class:
public void TrimPages(bool trimFirst, bool trimLast, bool ifBlank)
{
    var form = new TrimOptions();
    DialogResult result = form.ShowDialog();
    if (result == DialogResult.OK)
	{
		for (int entry = 0; entry < TotalPDFs; entry++)
		{
			PDFEntry thisFile = list[entry];
		}
	}
}

//thisFile Class:
public void Trim(bool front, bool back, bool ifBlank)
{
    // code
}
It seems to me that the class that manages the list of files should be the class that collects the various operation options, but I don't know which is the best practice, or what the implications are of doing it the second way.

modified 2-Jan-22 19:11pm.

AnswerRe: Opinions on two code layout alternatives? Pin
Gerry Schmitz11-Dec-21 6:08
mveGerry Schmitz11-Dec-21 6:08 
GeneralRe: Opinions on two code layout alternatives? Pin
RobertSF11-Dec-21 7:09
professionalRobertSF11-Dec-21 7:09 
GeneralRe: Opinions on two code layout alternatives? Pin
Gerry Schmitz11-Dec-21 7:43
mveGerry Schmitz11-Dec-21 7:43 
GeneralRe: Opinions on two code layout alternatives? Pin
RobertSF11-Dec-21 11:44
professionalRobertSF11-Dec-21 11:44 
AnswerRe: Opinions on two code layout alternatives? Pin
englebart29-Dec-21 15:56
professionalenglebart29-Dec-21 15:56 
GeneralRe: Opinions on two code layout alternatives? Pin
RobertSF2-Jan-22 13:10
professionalRobertSF2-Jan-22 13:10 
QuestionDocumentation or modeling tool for a DB-application Pin
Member 1331165719-Nov-21 19:43
Member 1331165719-Nov-21 19:43 
AnswerRe: Documentation or modeling tool for a DB-application Pin
Gerry Schmitz1-Dec-21 18:29
mveGerry Schmitz1-Dec-21 18:29 
AnswerRe: Documentation or modeling tool for a DB-application Pin
Mycroft Holmes2-Dec-21 11:01
professionalMycroft Holmes2-Dec-21 11:01 
GeneralRe: Documentation or modeling tool for a DB-application Pin
Member 133116573-Dec-21 4:55
Member 133116573-Dec-21 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.