What is the right approach for multi-page C# WPF desktop program?

How not to codding in only one file with C# WPF?

I’m graduating with a Computer Science degree recently and working as a C# WPF desktop application programmer now. I’m working on my first-ever project from zero on solo, but I am not sure what is the right approach to coding the multi-pages/windows program. In particular, I mean should I apply some pattern(such as MVP, MVVM) or just using some native ways that I ignored to avoid/handle some issues, such as:

  1. how to passing parameters and provoking commands in a class to another class without passing variables between source and target like this:

Passing parameter from a child(WindowB) to parent(WindowA):

public class WindowA {     string msg;     public WindowA() => new WindowB(msg);  } public class WindowB {     public WindowB(string msg) => msg = "Hello"; } 
  1. How to switch the page in a window?

I am taking MVVM Pattern approach now with Caliburn Micro and MVVM Light. But MVVM and most of the frameworks have a steep learning curve on the knowledge itself but also the vague/incomplete documents and tutorials. Is it an overkill option for a small project with only a few pages and not suitable for newbies? If yes, What is the right approach?

Which approach to display a preview of urls?

TL;DR I am currently trying to implement an URL preview for a chat feature (like on Whatsapp, Line, Telegram, etc) on mobile.

Stack: Mobile clients (iOS/Android app) and an API server (Django, MariaDB).

Flow: Users send to each other messages containing links to any website.

Goal: I want to display a preview of the URL using only meta tags (either Open Graph or basic meta tags).

I see 2 different approaches:

  • Server-driven: The clients (iOS/Android) ask the API for a preview of a link. The API server will fetch the URL directly if not in cache, then cache the result and serve it to the clients.
  • Client-driven: The clients directly fetch the link and display the preview.

Is there any other approach? Which one is the standard? Which one should be avoided?

For Messenger and Whatsapp, I believe the client requests Facebook API for a preview as Facebook has tons of OpenGraph preview data of almost all websites. But what about the others?

Best approach to design/display dashboard (kpi) using sharepoint kpi list

I have a sharepoint list with 70 kpi data points (i.e. month, goal/target, actual). What is the best way to display this data in sharepoint.

  1. i tried excel powerpivot based on the sharepoint list but i couldn’t get it work
  2. i tried performance point but i dont have multi-dimension or cube setup for this. The data are stored in the SharePoint list

Please suggest.

What is a user-friendly approach to exiting a preview screen?

I have a mobile Android application that allows users to specify through a form the layout of elements displayed to the screen. The user can also preview the customized layout in full-screen. However, use of the back button (soft key) is unavailable, and a navigational header adds clutter. Is there a clean, intuitive approach to respond to user input in order to exit the preview?

I have considered adding a button as well as tap to exit approach. A button is not very desirable because it adds clutter. In addition, the button may be assumed to be part of the preview. Allowing the user to tap to exit is okay, but I find the approach to be susceptible to accidental touches and not immediately intuitive to a user. Responding to multiple touches in a period of time is not a terrible approach; i.e. double tap.

What approach should i use to license a local web application with no internet?

I built a .Net web application for a company and it is going to be hosted on their own web-server that don’t have access to the internet. the solutions i have thought so far is to get the MAC address of the web-server and check it before the application runs, this will require to get every MAC address in the application and re-publish for every other deployment. And how can i make it to be renewable every year. The licence is only for one year.

Standard approach for tracking half-done features in Azure DevOps

We practice Scrum (SAFe) and use Azure DevOps to track features and PBIs. The team is unsure of how to handle features which have been started but not finished at the end of a program increment.

Half the team wants to move the feature back to the program backlog, but we then lose the ability to report on effort already spent on the feature, and the fact that our forecasts were wrong.

The other half of the team wants to clone the feature…which polluted our backlogs.

Is there any standard way to do this? I’d like an approach that doesn’t confuse new team members if possible.

What is a good approach for saving a Swift model that’s a struct containing structs to Core Data?

I’m new to Core Data, and am not sure how to reconcile the need to inherit from NSManagedObject with the fact that my model is a Swift struct composed of structs. I chose to make my a model value type so that it would be simple to push and pop it onto an undo stack. But since a value type can’t inherit, I’m unsure as to where to go next in order to save my model to the database. Should I turn my model into a class and use UndoManager instead? What might be some other possible approaches?

C++ Functional Programming: How can I convert nested loops into functional approach?

I first created my function using an imperative approach. This is just how I naturally write code most of the time. I then tried to think about the problem using a “What I want to accomplish?” approach, rather than “What do I want it to do?” In the end I think I still ended up with an imperative approach, just using STL algorithms as loops.

The code itself pre-calculates the winning combinations for an n-sized tic tac toe board.

Imperative approach:

std::vector<std::vector<int>> rules3(const int x){     using namespace std;      vector<vector<int>> seqs;     for(int n=0; n<x; ++n){         vector<int> seq;         for(int m=0; m<x; ++m){             seq.push_back(n*x+m);         }         seqs.push_back(seq);     }     for(int n=0; n<x; ++n){         vector<int> seq;         for(int m=0; m<x; ++m){             seq.push_back(n+x*m);         }         seqs.push_back(seq);     }     vector<int> seq;     for(int n=0; n<x; ++n){         seq.push_back(n*x+n);     }     seqs.push_back(seq);     seq.clear();     for(int n=0; n<x; ++n){         seq.push_back(x-1+n*(x-1));     }     seqs.push_back(seq);      return seqs; } 

Getting more functional:

std::vector<std::vector<int>> rules2(const int x){     using namespace std;      vector<vector<int>> seqs;     vector<int> iter(x);     iota(iter.begin(), iter.end(), 0);      for(auto n: iter){         vector<int> seq;         for(auto m: iter){             seq.push_back(n*x+m);         }         seqs.push_back(seq);     }     for(auto n: iter){         vector<int> seq;         for(auto m: iter){             seq.push_back(n+x*m);         }         seqs.push_back(seq);     }     vector<int> seq;     seq.clear();     for(auto n: iter){         seq.push_back(n*x+n);     }     seqs.push_back(seq);     seq.clear();     for(auto n: iter){         seq.push_back(x-1+n*(x-1));     }     seqs.push_back(seq);      return seqs; } 

Functional approach? (still feels imperative):

std::vector<std::vector<int>> rules1(const int x){     using namespace std;      vector<vector<int>> seqs;     vector<int> iter(x);     iota(iter.begin(), iter.end(), 0);      transform(iter.begin(), iter.end(), back_inserter(seqs), [&](const int& n){         vector<int> seq;         transform(iter.begin(), iter.end(), back_inserter(seq), [&](const int& m){             return n*x+m;         });         return seq;     });     transform(iter.begin(), iter.end(), back_inserter(seqs), [&](const int& n){         vector<int> seq;         transform(iter.begin(), iter.end(), back_inserter(seq), [&](const int& m){             return n+x*m;         });         return seq;     });     vector<int> seq;     transform(iter.begin(), iter.end(), back_inserter(seq), [&](const int& n){         return n*x+n;     });     seqs.push_back(seq);     seq.clear();     transform(iter.begin(), iter.end(), back_inserter(seq), [&](const int& n){         //return (x-n-1)*x+n; // 6,4,2         return x-1+n*(x-1); // 2,4,6     });     seqs.push_back(seq);      return seqs; } 

Output when printing:

rules3 std::vector(0, 1, 2) std::vector(3, 4, 5) std::vector(6, 7, 8) std::vector(0, 3, 6) std::vector(1, 4, 7) std::vector(2, 5, 8) std::vector(0, 4, 8) std::vector(2, 4, 6) rules2 std::vector(0, 1, 2) std::vector(3, 4, 5) std::vector(6, 7, 8) std::vector(0, 3, 6) std::vector(1, 4, 7) std::vector(2, 5, 8) std::vector(0, 4, 8) std::vector(2, 4, 6) rules1 std::vector(0, 1, 2) std::vector(3, 4, 5) std::vector(6, 7, 8) std::vector(0, 3, 6) std::vector(1, 4, 7) std::vector(2, 5, 8) std::vector(0, 4, 8) std::vector(2, 4, 6) 

“Is this a valid approach to retrieve complex objects?”

Suppose I have a complex object Person that depends on several other objects:

class Person {     int id;     String name;     Vehicle vehicle;     Job job;     Preference preference; }  class Vehicle {     int id;     String name; }  class Job {     int id;     String name; }  class Preference {     int id;     String name; } 

This scheme translates into 4 tables: persons, vehicles, jobs and preferences.

CREATE TABLE vehicles(id SERIAL PRIMARY KEY, name VARCHAR); CREATE TABLE jobs(id SERIAL PRIMARY KEY, name VARCHAR); CREATE TABLE preferences(id SERIAL PRIMARY KEY, name VARCHAR); CREATE TABLE persons(id SERIAL PRIMARY KEY, name VARCHAR, vehicle INTEGER REFERENCES vehicles(id), job INTEGER REFERENCES jobs(id), preference INTEGER REFERENCES preferences(id)) 

In order to retrive and construct a complete object, I would do something like this:

1) Retrieve a collection of persons without nested objects (use only id references);

class PersonSimple {     int id;     String name;     int vehicle;     int job;     int preference; }  List<PersonSimple> personsSimple = PersonsDataAccessObject.get(); // SELECT * FROM persons; jdbc here  

2) Retrieve collections of nested objects

List<Vehicle> vehicles = VehiclesDataAccessObject.get(); // SELECT * FROM vehicles; jdbc here List<Job> jobs = JobsDataAccessObject.get(); // SELECT * FROM jobs; jdbc here List<Preference> preference = PreferenceDataAccessObject.get(); // SELECT * FROM preferences; jdbc here 

3) Combine everything

List<Person> persons = new ArrayList<Person>;  for (PersonSimple personsSimple : personsSimple) {     Person person = new Person();      person.setId(personSimple.getId());     person.setName(personSimple.getName());      //     Optional<Vehicle> vehicle = vehicles.stream().filter(v -> v.getId() == person.getVehicle()).findFirst();      if (position.isPresent())     {         person.setVehicle(vehicle.get());     }      //     Optional<Job> job = jobs.stream().filter(j -> j.getId() == person.getJob()).findFirst();      if (job.isPresent())     {         person.setJob(job.get());     }      //     Optional<Preference> preference = jobs.stream().filter(p -> p.getId() == person.getJob()).findFirst();      if (preference.isPresent())     {         person.setPreference(preference.get());     }      persons.add(person); } 

Step 3 is what worries me, particularly lines like

vehicles.stream().filter(v -> v.getId() == person.getVehicle()).findFirst();` and similar lines 

I kinda understand that this approach is going to be slow, but by doing this, field vehicle of Person object would reference the same memory that is reference by the object inside vehicles collection which sounds right to me.

It allows me to modify objects of vehicles collection and reflect these changes on existing objects in persons collection.

  • Is it a correct solutions or is there there a deep misunderstanding and plain bad practice?
  • I am not sure, but it feels like I should replace it with GROUP BY, following with a correct implementation of client-side code. Is it true?
  • If this approach is valid, is there any point in replacing List (and similar) with Map where field “id” would be the key?
  • This PersonSimple to Person translation feel like a total hack.

Should I pull entire Person object from database via

SELECT * FROM persons INNER JOIN vehicles ON (persons.vehicle = vehicles.id) INNER JOIN jobs ON (persons.job = jobs.id) INNER JOIN preferences ON (persons.preference = preferences.id); 

Then how would I provide automatic selection of valid items inside, for example, ComboBoxTableCell if objects referenced by fields would not be object from the collection (same data but different instances/memory).

Is there a common approach to solution design? [on hold]

Specifically greenfield solution design, but I’d also like to know if there’s a common approach that would also apply to brownfield development and extensions to existing systems.

I ask because I had a whiteboarding interview for solution design, and realise a structured approach I could run through quickly for a simple question would have served me better.

Input: brief, output: domain model and component architecture

My steps were:

  • define the terms/language, leading to concepts/entities
  • design entity relationships to discover business rules
  • design use cases to understand roles and their available functions/actions/commands
  • design data-flow to understand solution inputs and outputs / interfaces
  • …. then what? …
  • component diagram (client, server, MVC, API, DB, message bus, etc.)

Is there a more commonly recognised way to achieve the above? I’m aware of DDD (learning) but does it cover everything down to choosing MVC vs other patterns, when to use message bus, etc? At what stage do you define the suitable design patterns to use?