0% found this document useful (0 votes)
4 views

CodeSmell

Uploaded by

Minahil Ismail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

CodeSmell

Uploaded by

Minahil Ismail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

public class Customer

{
public void CreateAccount(string firstName, string lastName, string
email, string phone, string address, string city, string zipCode)
{
Console.WriteLine($"Creating account for {firstName} {lastName} with
email {email}.");

}
}

public class CustomerInfo


{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string ZipCode { get; set; }
}

public class Customer


{
public void CreateAccount(CustomerInfo customerInfo)
{
Console.WriteLine($"Creating account for {customerInfo.FirstName}
{customerInfo.LastName} with email {customerInfo.Email}.");
}
}

public class ReportGenerator


{
public void GenerateReport()
{
Console.WriteLine("Starting report generation...");

// Section 1: Data collection


Console.WriteLine("Collecting data...");
// Many lines of code for data collection

// Section 2: Data processing


Console.WriteLine("Processing data...");
// Many lines of code for data processing

// Section 3: Data formatting


Console.WriteLine("Formatting data...");
// Many lines of code for data formatting

// Section 4: Report saving


Console.WriteLine("Saving report...");
// Many lines of code for saving the report

Console.WriteLine("Report generation completed.");


}
}

public class ReportGenerator


{
public void GenerateReport()
{
Console.WriteLine("Starting report generation...");
CollectData();
ProcessData();
FormatData();
SaveReport();
Console.WriteLine("Report generation completed.");
}

private void CollectData()


{
Console.WriteLine("Collecting data...");
// Code for data collection
}
private void ProcessData()
{
Console.WriteLine("Processing data...");
// Code for data processing
}

private void FormatData()


{
Console.WriteLine("Formatting data...");
// Code for data formatting
}
private void SaveReport()
{
Console.WriteLine("Saving report...");
// Code for saving the report
}
}

public class Employee


{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public string Department { get; set; }
public string Position { get; set; }
public decimal Salary { get; set; }
public string TaxId { get; set; }
public DateTime HireDate { get; set; }

public void CalculateSalary() { /* salary calculation code */ }


public void GeneratePaySlip() { /* pay slip generation code */ }
public void ApplyForLeave() { /* leave application code */ }
public void ReviewPerformance() { /* performance review code */ }
public void UpdateContactDetails() { /* update contact code */ }
public void Promote() { /* promotion code */ }
public void TransferDepartment() { /* department transfer code */ }
public void TerminateEmployment() { /* termination code */ }
}

class EmployeeInfo
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
}

class JobDetails
{
public string Department { get; set; }
public string Position { get; set; }
public decimal Salary { get; set; }
public string TaxId { get; set; }
public DateTime HireDate { get; set; }

public void CalculateSalary() { /* salary calculation code */ }


public void GeneratePaySlip() { /* pay slip generation code */ }
}

public class EmployeeManagement


{
public void ApplyForLeave() { /* leave application code */ }
public void ReviewPerformance() { /* performance review code */ }
public void Promote() { /* promotion code */ }
public void TransferDepartment() { /* department transfer code */ }
public void TerminateEmployment() { /* termination code */ }
}

public class Employee


{
public EmployeeInfo Info { get; set; }
public JobDetails Job { get; set; }
public EmployeeManagement Management { get; set; }

public Employee()
{
Info = new EmployeeInfo();
Job = new JobDetails();
Management = new EmployeeManagement();
}
}

public class Customer


{
public Order GetOrder() => new Order();
}

public class Order


{
public Delivery GetDelivery() => new Delivery();
}

public class Delivery


{
public DateTime GetDeliveryDate() => DateTime.Now.AddDays(5);
}

class Program
{
static void Main()
{
Customer customer = new Customer();
DateTime deliveryDate =
customer.GetOrder().GetDelivery().GetDeliveryDate();
Console.WriteLine($"Delivery Date: {deliveryDate}");
}
}
public class Customer
{
private Order order = new Order();

public DateTime GetDeliveryDate()


{
return order.GetDelivery().GetDeliveryDate();
}
}

public class Order


{
public Delivery GetDelivery() => new Delivery();
}

public class Delivery


{
public DateTime GetDeliveryDate() => DateTime.Now.AddDays(5);
}

class Program
{
static void Main()
{
Customer customer = new Customer();
DateTime deliveryDate = customer.GetDeliveryDate(); // Simplified
method call
Console.WriteLine($"Delivery Date: {deliveryDate}");
}
}

You might also like