clean code – best approach of passing arguments from usecases to repositories

I want to pass interface as a request in my use cases and repositories while following the clean architecture in flutter

hence my method signature is as follows for usecases and respositories respectively.

Future<Either<Failure, ResponseData>> call(IRequest params) // use case
Future<Either<Failure, ResponseData>> updateUserProfile(IRequest request); // repository

Now request entities and models are as follows

//Entity
class UserProfileRequestData  implements IRequest{


  late final int id;
  late final String first_name;
  late final String last_name;
  
   UserProfileRequestData(
      {required this.id,
      required this.first_name,
      required this.last_name});
      
 @override
  Object toRequest() {
    // TODO: implement toRequest
    throw UnimplementedError();
  }
}

//Model
class UserProfileRequestDataModel extends UserProfileRequestData implements IRequest {

     UserProfileRequestDataModel({
        required int id,
        required String first_name,
        required String last_name,}):super( id: id,
            first_name: first_name,
            last_name: last_name,);
            
     Map<String, dynamic> toJson() {
    return {
      "first_name": first_name,
      "last_name": last_name,
      "id": id,
      };
   }
    @override
  Map<String, dynamic> toRequest() => toJson();


}

Now, what I am expecting is whenever the user passes UserProfileRequestData as an entity from UI and in repository if I execture request.toRequest() then it should call UserProfileRequestDataModel‘s toRequest() function and not the parent class one.

here is the sample code for this problem statement

I have gone through the articles and it looks like it requires Mapper classes to convert the Entities into Model but again that creates more tiresome code when nested classes are involved. Is there a better way to pass the data from the domain layer to the data layer?

python – How to balance ‘efficient’ vs ‘clean’ code?

I have been coding in python for a little over a year, and I have learned a lot and developed quite a few applications, in the process.

I do not program for my profession, I simply program recreationally. With that said, I am not exposed to new programming techniques/data structures etc., that I would be learning if my day job was in the field, for example.

I have become quite good at figuring out what I want to do by trial and error in python, and I am usually pretty successful at figuring it out!

However, sometimes when I learn something new, I will find that I was doing it the long way or with way too much code that could be much more easily accomplished with fewer lines or a technique that makes an algorithm more efficient.

When you are developing software, do you strive to find the most efficient way to do something first, or do you simply code the way you are familiar?

I don’t have many programmer friends, so I have been doing this all pretty much on my own.

I watch a few twitch streams, but beside that I do not really know anyone in person.

Hopefully that adds some context why I am asking.

clean architecture – How can I manage dependency injection in test code?

This question is a follow-up question to Clean Architecture use case testing.

Suppose the production code injects Use Case Interactor into the Input Boundary – that happens somewhere in the main component1. But now I want to test the Input Boundary/Output Boundary of the use case. I can only think of two ways to do this:

  1. Recreate the dependency injection setup at the beginning of the test – this forces the test to depend on Use Case Interactor.
  2. Depend on the main component for DI – this seems risky because the main component is volatile.

Is there a clean way to handle this situation?

1 Clean Architecture Chapter 26, Robert C Martin

python – How are you sure if you are developing something with efficient or ‘clean’ code?

I have been coding in python for a little over a year, and I have learned a lot and developed quite a few applications, in the process.

I do not program for my profession, I simply program recreationally. With that said, I am not exposed to new programming techniques/data structures etc., that I would be learning if my day job was in the field, for example.

I have become quite good at figuring out what I want to do by trial and error in python, and I am usually pretty successful at figuring it out!

However, sometimes when I learn something new, I will find that I was doing it the long way or with way too much code that could be much more easily accomplished with fewer lines or a technique that makes an algorithm more efficient.

When you are developing software, do you strive to find the most efficient way to do something first, or do you simply code the way you are familiar?

I don’t have many programmer friends, so I have been doing this all pretty much on my own.

I watch a few twitch streams, but beside that I do not really know anyone in person.

Hopefully that adds some context why I am asking.

SQLI DUMPER V.10.3 – V.10.2 – V.9.7 – V.8.5 – V.8.2 – V.8.0 – V.7.0 (ALL STABLE & CLEAN VERSIONS) | Proxies-free

  1. sitehunter
    New Member


    Joined:
    Yesterday
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Female

    (​IMG)
    Fixed most of known bugs, All Dorks will be scanned now, cleaned from any trojan
    Available Versions:
    SQLi Dumper v.10.3 ( Clean & Stable) – issues Fixed
    SQLi Dumper v.10.2
    SQLi Dumper v.9.7
    SQLi Dumper v.8.5
    SQLi Dumper v.8.2
    SQLi Dumper v.8.0
    SQLi Dumper v.7.0
    —————————————————————————————————————————–
    SQLi Dumper v.10.3
    Download Link :

    Hidden Content:

    You must reply before you can see the hidden data contained here.

    VirusTotal:
    https://www.virustotal.com/gui/file…0c6d269cc56bfd127265a406e75de9fb802/detection

     

antivirus – Windows Defender catches Trojan right after clean install

I recently upgraded some desktop PC components (GPU, SSD). I decided to perform a clean install of Windows 10 onto the SSD. I used a USB created using the Installation Media tool provided by Microsoft, which I created on my personal laptop.

During the initial Windows Update after the first restart, a Trojan “Trojan:HTML/Phish.GR!MSR” is immediately identified, without me doing anything else aside from the Windows Update. No webpages visited, no files downloaded, nothing.

I’m no security expert, so I tried swapping my old parts with the upgraded ones to control the cause and check if my new components had anything to do with it, but it appears randomly. I suspect it’s the installation USB, but not sure.

Any idea what could cause this? What can I do if I can’t even trust a clean Windows install?!

entity – Clean Architecture, what are objects that does not completely fit as entities?

I’m reading chapter 20, “Business Rules”, of clean architecture book, in this chapter Uncle Bob defines entities as:

An Entity is an object within our computer system that embodies a
small set of critical business rules operating on Critical Business
Data. The Entity object either contains the Critical Business Data or
has very easy access to that data. The interface of the Entity
consists of the functions that implement the Critical Business Rules
that operate on that data.

I understand that entities are domain objects that could be used in any context of the application because it’s “self-sufficient” with its own rules and validations, but what about objects that do not have “strong” and “critical” business rules that could be used in any context? just simple data holders, anemic classes, are they considered domain objects? can use-cases be coupled to them just like it is to entities?

A simple example of a specific scenario:

I have a Use Case to create blog posts with images, in which the user can send URLs of images uploaded on an amazon s3 server, and in the back-end there’s a check to see if the provided URLs are valid, if so the post is created with these images URLs.

On the Use Case, for the URL check I use the Amazon S3 API encapsulated as a generic adapter, something like ImageStorageAdapterInterface with the method getImageByUrl(), which returns a simple object with metadata such as url, created_at, expire_at, size, and so…

I could have considered this object as an entity and name it something like UploadedImageUrl or TemporaryImageUrl, but I couldn’t see this particular object as an entity because it is not an object with “critical business rules”, but just a simple “auxiliary” object, with very few methods (if any) and I don’t think this object meets uncle bob’s definition of an entity.

I know that a lot of things are subjective and depend on the context, but this dilemma is very common on a daily basis.

What are these kinds of objects that do not fit as an entity?

Should I always try to find a common ground on my domain and “extract” an entity of these cases?

Could this still be considered as a domain object (even if it’s simple)?

Make clean install of Ubuntu 20.04/Windows image it and deploy to 10 computers

I am currently working on new project, where I have to install a clean system (Ubuntu 20/ Windows 10). Install all needed software, make and image of these system (Ubuntu and Windows), then deploy on few other computer (10 to 15 computers). The computer hardware are almost the same. I know there a different tools for Ubuntu and Windows.

But I need few hint for this project.

Feel free to give me any proposition, I need direction.

Thanks.

c# – I am a beginner. I was wondering if my code has any unneccesary/bad code that I need to clean of

This is a hangman game. The only word is ‘word’ and I am not planning on changing this since I am not going to publish this game or anything. Here is my code:

using System;
using System.Threading;

namespace Hangman
{
    class Program
    {
        static void Restart()
        {
            try
            {
                Console.Write("restart? (y/n): ");

                char restart_input = Convert.ToChar(Console.ReadLine().ToLower());

                if(restart_input == 'y')
                {
                    Console.WriteLine("----------");
                    Main();
                }
                
                else if (restart_input == 'n')
                {
                    Console.Write("nPress any key to exit");
                    Console.ReadKey();
                }
                
                else if (restart_input != 'y' && restart_input != 'n')
                {
                    Console.WriteLine("ninvalid input");
                    Restart();
                }

            }

            catch(Exception e)
            {
                Console.Write("n" + e);
                Restart();
            }

        }

        static void Main()
        {
            Console.Title = "Hangman";

            int i = 0;
            int j = 1;

            bool has_guessed_the_letter = false;

            string word = "word";

            int failed_attempts = 0;
            int score = 0;

            Random random = new Random();
            int random_int = random.Next(0, 2);

            char() char_array = word.ToCharArray();
            char?() hidden_letters = new char?(i);

            foreach (char letter in char_array)
            {
                switch (random_int)
                {
                    case 1:
                        Console.Write(letter);
                        Thread.Sleep(200);
                        random_int = random.Next(0, 2);
                        break;

                    case 0:
                        Console.Write("_");
                        Thread.Sleep(200);
                        random_int = random.Next(0, 2);
                        Array.Resize(ref hidden_letters, j);
                        hidden_letters(i) = letter;
                        i++;
                        j++;
                        break;
                }
            }

            if (hidden_letters.Length == 0)
            {
                Console.Write("nthere are no hidden letters, lucky :)");
            }
            
            else if (hidden_letters.Length == word.Length)
            {
                Console.Write("nall letters are hidden, no luck :(");
            }
            
            else
            {           
                try
                {
                    label:

                    i = 0;
                    j = 1;

                    has_guessed_the_letter = false;

                    Console.Write("nninput: ");

                    char user_input = Convert.ToChar(Console.ReadLine());

                    while (has_guessed_the_letter == false && j <= hidden_letters.Length)
                    {
                        if (user_input == hidden_letters(i))
                        {
                            has_guessed_the_letter = true;
                            hidden_letters(i) = null;
                        }

                        else
                        {
                            i++; j++;
                        }

                    }

                    if (has_guessed_the_letter == true)
                    {
                        Console.WriteLine("Congratulations! " + j + ". hidden letter was " + user_input);
                        score++;                             
                        if (score == hidden_letters.Length)
                        {
                            Console.Write("nCongratulations! the hidden word was: " + word);
                        }
                        else
                        {
                            Console.WriteLine("score: " + score + " (must reach: " + hidden_letters.Length + ")");
                            Console.Write("failed attempts: " + failed_attempts + " (failed attempts left: " + ((word.Length * 2) - failed_attempts) + ")");
                            goto label;
                        }
                    }
                    else
                    {
                        Console.WriteLine("failed attempt: " + user_input);
                        failed_attempts++;
                        if (failed_attempts == (word.Length * 2))
                        {
                            Console.Write("ngame over. the hidden word was: " + word);
                        }
                        else
                        {
                            Console.WriteLine("score: " + score + " (must reach: " + hidden_letters.Length + ")");
                            Console.Write("failed attempts: " + failed_attempts + " (failed attempts left: " + ((word.Length * 2) - failed_attempts) + ")");
                            goto label;
                        }
                    }
                }

                catch(Exception e)
                {
                    Console.Write("n" + e);
                }                
            }
            Console.WriteLine("n----------");
            Restart();
        }
    }
}

If there is any unneccesary/bad code I need to get rid of, please tell me.