0% found this document useful (0 votes)
112 views8 pages

Web App Development & Code Review Guide

The user story describes a requirement for a web application that allows customers to register, authenticate, and submit documents (PDF and Excel files larger than 1-2GB) to a database. The application needs to validate passwords based on complexity rules and send success notifications. It also needs to allow a business unit to monitor and download submitted documents. The task is to develop this web application using .NET Core 7, EF Core, and a clean architecture pattern.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views8 pages

Web App Development & Code Review Guide

The user story describes a requirement for a web application that allows customers to register, authenticate, and submit documents (PDF and Excel files larger than 1-2GB) to a database. The application needs to validate passwords based on complexity rules and send success notifications. It also needs to allow a business unit to monitor and download submitted documents. The task is to develop this web application using .NET Core 7, EF Core, and a clean architecture pattern.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

LOGICAL AND REVIEW CODE

AND
BUILD WEB APP TEST BASED ON USE
STORY

LEMBAGA PEMJAMIN SIMPANAN


2023

GROUP SISTEM INFORMASI


DIVISI PENGEMBANGAN APLIKASI

This file and its contents and format are the property of the Deposit Insurance Corporation (IDIC). It is not
permitted to be distributed, duplicated and/or used in part or in whole in any form without prior written
permission from LPS except for the purposes of carrying out this work.
Goals:

This text is intended to measure the ability to write coding as well as measure the ability to carry out
coding reviews.

Another technical measurement the candidate should be proven in web application development
using clean architecture pattern.

Task:

• Please re-write the code, doing coding, analysing and fixing the code! (question number 1 to
7). Crate a solution using Microsoft Visual Studio and store all source code to [Link] and
create [Link] to explain your opinion!
• For number 8 read user story carefully and doing the task, and do not forget to store the code
in [Link]
A. Logical and Review Code

1. How about your opinion..?

if (application != null)
{
if ([Link] != null)
{
return [Link];
}
}

Key:
cleaner and easier to read code.

2. How about your opinion.

public ApplicationInfo GetInfo()


{
var application = new ApplicationInfo
{
Path = "C:/apps/",
Name = "[Link]"
};
return application;
}

Key:
return more than one value from a class method.

3. How about your opinion.

class Laptop
{
public string Os{ get; set; } // can be modified
public Laptop(string os)
{
Os= os;
}
}
var laptop = new Laptop("macOs");
[Link]([Link]); // Laptop os: macOs

Key:
modifications by using private members.
4. How about your opinion?

using System;
using [Link];

namespace MemoryLeakExample
{
class Program
{
static void Main(string[] args)
{
var myList = new List();
while (true)
{
// populate list with 1000 integers
for (int i = 0; i < 1000; i++)
{
[Link](new Product([Link]().ToString(), i));
}
// do something with the list object
[Link]([Link]);
}
}
}

class Product
{
public Product(string sku, decimal price)
{
SKU = sku;
Price = price;
}

public string SKU { get; set; }


public decimal Price { get; set; }
}
}

Key:
Keeping references to objects unnecessarily
5. How about your opinion?

using System;
namespace MemoryLeakExample
{
class Program
{
static void Main(string[] args)
{
var publisher = new EventPublisher();

while (true)
{
var subscriber = new EventSubscriber(publisher);
// do something with the publisher and subscriber objects
}
}

class EventPublisher
{
public event EventHandler MyEvent;

public void RaiseEvent()


{
MyEvent?.Invoke(this, [Link]);
}
}

class EventSubscriber
{
public EventSubscriber(EventPublisher publisher)
{
[Link] += OnMyEvent;
}

private void OnMyEvent(object sender, EventArgs e)


{
[Link]("MyEvent raised");
}
}
}
}

Key:
event handlers
6. How about your opinion?

using System;
using [Link];
namespace MemoryLeakExample
{
class Program
{
static void Main(string[] args)
{
var rootNode = new TreeNode();
while (true)
{
// create a new subtree of 10000 nodes
var newNode = new TreeNode();
for (int i = 0; i < 10000; i++)
{
var childNode = new TreeNode();
[Link](childNode);
}
[Link](newNode);
}
}
}

class TreeNode
{
private readonly List<TreeNode> _children = new List<TreeNode>();
public void AddChild(TreeNode child)
{
_children.Add(child);
}
}
}

Key:
Large object graphs
7. How about your opinion?

using System;
using [Link];
class Cache
{
private static Dictionary<int, object> _cache = new Dictionary<int,
object>();

public static void Add(int key, object value)


{
_cache.Add(key, value);
}

public static object Get(int key)


{
return _cache[key];
}
}

class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 1000000; i++)
{
[Link](i, new object());
}

[Link]("Cache populated");

[Link]();
}
}

Key:
Improper caching
B. Web Application Development using Clean Architecture

No 1. Read User Story below carefully:

The business unit require a web application to receive document (xlsx and pdf) from customer and
store those documents into database. Before send the required documents customer should be
register if not registered yet. System should be authenticated the user as customer before send
documents to the system. In Password should be fulfilled with requirements as stated below:

• It contains at least one lowercase English character.


• It contains at least one uppercase English character.
• It contains at least one special character. The special characters are: !@#$%^&*()-+
• Its length is at least 8.
• It contains at least one digit.

When documents store successfully in database (transaction completely), system send notification
to customer as receipt that document is submitted successfully. The size of Documents are more than
1 or 2 GBs, and technically required handling like chunking method.

The business unit able to monitor the documents which sent by customers and unit business able to
download those documents.

Task:

Develop web application using clean architecture web API .net core 7, and entity framework using c#.

Common questions

Powered by AI

Handling large documents efficiently in web applications can be achieved by implementing techniques such as chunking and streaming. Chunking involves breaking down large files into smaller, manageable parts that can be processed incrementally, reducing memory usage and improving upload/download reliability. Streaming allows data to be processed as it is being received or sent, which minimizes memory consumption and enhances the application's ability to handle large files without blocking operations. Together, these techniques facilitate the effective management of large documents while maintaining application performance and user experience .

In C#, to prevent memory leaks in scenarios involving large object graphs, it's essential to manage object references correctly. This can be done by explicitly managing the scope of objects and ensuring that references to large objects are removed when they are no longer needed. Using data structures that manage memory effectively, such as weak references, can help. For instance, employing weak references allows garbage collection to reclaim the memory even if references to it still exist, thereby preventing memory leaks. Additionally, tools such as .NET memory profiler can be used to detect and diagnose memory leaks in applications .

The clean architecture pattern enhances maintainability and scalability in web application development by enforcing a clear separation of concerns. This pattern divides applications into layers, each responsible for distinct logic. The independence of layers from database, frameworks, and user interfaces allows changes to be made in one part without impacting others, thus aiding maintainability. Scalability is improved as the architecture supports growth in functionality and complexity by isolating business rules from the rest of the system, enabling easier adaptation to changes and expansions in requirements .

Event handlers in C# can lead to memory leaks if they are not properly managed due to lingering references. When an object subscribes to an event and the event is never unsubscribed or the object is not disposed of correctly, the garbage collector can fail to reclaim the memory used by the object. This is because the publisher holds a reference to the subscriber through the event handler, thus preventing the subscriber from being garbage collected . To mitigate this problem, implementing weak event patterns or explicitly unregistering event handlers when they are no longer needed are effective strategies.

Improper caching strategies, especially in high-frequency access patterns, can lead to issues such as memory bloat and reduced application performance. When cache entries are not managed correctly, the cache can consume excessive memory, leading to system resource exhaustion or increased garbage collection pressure. Additionally, if cache invalidation strategies are not properly implemented, stale data might be served, leading to inconsistent application state. It is crucial to implement efficient eviction policies and ensure that the cache is neither underutilized nor overfilled, thus balancing performance gains with resource usage .

Using private members in class design is vital for enforcing encapsulation in object-oriented programming, as it restricts direct access to the internal state of an object from outside the class. Encapsulation hides the complexities of the object's state and behavior, allowing modifications to be made without affecting the external code that relies on the public interface. This promotes a controlled interaction with the object's data through methods, which ensures that the state remains consistent and relevant invariants are maintained. Consequently, it enhances the modularity and robustness of the code .

Microsoft Visual Studio and GitHub support the collaborative development of .NET applications by providing a seamless integration of development tools with version control capabilities. Visual Studio offers a robust environment for coding, debugging, and testing, which enhances developer productivity. GitHub, on the other hand, facilitates version control, enabling multiple developers to work on the same project simultaneously while managing code changes and collaboration through branches and pull requests. This integration promotes efficient teamwork, code sharing, and project tracking, ensuring quality and consistency in the software development process .

Thread pooling in .NET optimizes application performance by reusing threads for handling multiple asynchronous events, reducing the overhead associated with thread creation and destruction. It ensures that the system's resources are effectively utilized without creating too many threads, which might degrade performance. Proper synchronization mechanisms, such as locks or using the Task Parallel Library, coordinate access to shared resources, preventing race conditions and ensuring data integrity. These strategies combined enable a responsive application that can handle numerous events efficiently while maintaining stability .

A clean architecture in .NET Core follows principles such as separation of concerns and dependency inversion. It involves organizing code into layers (e.g., presentation, application, domain, infrastructure) where each layer has a clear responsibility and only interacts with adjacent layers. This separation simplifies testing and maintenance by isolating business logic from platform-specific code. Dependency inversion further decouples components by defining high-level policies in the application core, while implementations reside in peripheral layers. This leads to a more flexible and maintainable codebase, allowing easier adaptations to changes in business requirements without affecting other parts of the system .

Password complexity requirements are crucial in user authentication systems as they significantly reduce the risk of unauthorized access due to weak or easily guessable passwords. Enforcing rules such as including uppercase letters, lowercase letters, special characters, and minimum length increases the difficulty for attackers attempting to crack passwords using methods such as brute force or dictionary attacks. This enhances the overall security posture of a system by ensuring that user credentials are robust against potential attacks, thus protecting sensitive information stored within the system .

You might also like