<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Halil Toksöz on Medium]]></title>
        <description><![CDATA[Stories by Halil Toksöz on Medium]]></description>
        <link>https://medium.com/@haliltoksz?source=rss-d6a539034905------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wZndSAUOIHqBXB53PR_iRw.jpeg</url>
            <title>Stories by Halil Toksöz on Medium</title>
            <link>https://medium.com/@haliltoksz?source=rss-d6a539034905------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:40:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@haliltoksz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mastering gRPC: The Ultimate Guide]]></title>
            <link>https://medium.com/@haliltoksz/mastering-grpc-the-ultimate-guide-9e6e65ff9f71?source=rss-d6a539034905------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e6e65ff9f71</guid>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[grpc]]></category>
            <dc:creator><![CDATA[Halil Toksöz]]></dc:creator>
            <pubDate>Mon, 16 Oct 2023 08:20:17 GMT</pubDate>
            <atom:updated>2023-10-16T13:14:21.456Z</atom:updated>
            <content:encoded><![CDATA[<h3>An Introduction to gRPC: Efficient Communication for Modern Applications</h3><h3>Introduction</h3><p>In the current age of software development, choosing the right communication protocol can significantly impact the performance, scalability, and maintainability of applications. Enter gRPC, a modern communication protocol that stands out due to its efficiency and versatility. This guide dives deep into gRPC, contrasting it with the likes of REST and GraphQL, and offers an in-depth understanding of its inner workings and benefits.</p><p>In this blog post, we’ll delve into the nuts and bolts of gRPC and Protocol Buffer, including how they work and the methods and techniques they use. We’ll also explore the differences between HTTP 1.1 and HTTP 2, gRPC communication types and core principles, as well as the pros and cons of gRPC. Furthermore, we’ll compare gRPC’s performance with REST and GraphQL and discuss when it’s a better option than REST or GraphQL. Finally, we’ll provide a step-by-step tutorial on how to create a Nest.js gRPC client with a gRPC server using .NET Core, so you can get started with gRPC today!</p><h3>What is gRPC?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*rshtKhD8NH_sLzJRGA1_AQ.png" /><figcaption>RPC</figcaption></figure><p><strong>Remote Procedure Call (RPC)</strong> is a <strong>client-server communication protocol</strong> that enables one program to request a service from another program on a network without requiring knowledge of the network’s underlying details. RPC is frequently used to implement microservices architectures, which enable multiple requests to be performed concurrently using lightweight processes or threads that share the same address space.</p><p>A procedure call, also known as a function call or subroutine call, is a <strong>synchronous operation</strong> that requires the requesting program to be <strong>suspended until the results</strong> of the remote procedure are returned. The <strong>Interface Definition Language (IDL)</strong> is commonly used in RPC software to specify a software component’s application programming interface (API). <strong>IDL acts as a bridge</strong> between machines at either end of the link that may be using different operating systems and computer languages, allowing them to communicate effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*ePnIAQlQzjAAhfE4y-NTnw.png" /><figcaption>gRPC</figcaption></figure><p><strong>gRPC</strong>, which stands for Google Remote Procedure Call, is an open-source high-performance framework that enables efficient communication between services. It was initially developed by Google and is now being used and supported by a growing number of organizations.</p><h3>Protocol Buffers</h3><p>A standout feature of gRPC is its use of Protocol Buffers (protobuf) — a binary serialization format. Unlike JSON or XML which are used in REST, protobufs are more compact and faster to parse, resulting in smaller payloads and quicker transmission times.</p><h3>How does gRPC work?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ju6WuxhY-RZcS5b1-wYZJg.png" /><figcaption>How does gRPC work?</figcaption></figure><p>gRPC uses HTTP/2 to transmit data between clients and servers. HTTP/2 is a binary protocol that is more efficient than HTTP/1.1.</p><p><strong>gRPC uses Protocol Buffers to serialize data.</strong> Protocol Buffers are a compact and efficient way to serialize data.</p><p><strong>gRPC uses a client-server architecture.</strong> The client sends requests to the server, and the server sends responses to the client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*VIVZbKhbqXkUsb9_jF8udw.png" /><figcaption>gRPC Workflow</figcaption></figure><h3>gRPC lifecycle and workflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5QiM5qFcfJGwHFGjpC7ueg.png" /><figcaption>gRPC Workflow</figcaption></figure><p>The gRPC lifecycle and workflow can be summarized as follows:</p><ol><li><strong>Client and server initialization:</strong> The client and server initialize the gRPC libraries.</li><li><strong>Client-side service discovery:</strong> The client discovers the server’s address.</li><li><strong>Client-side connection establishment:</strong> The client establishes a connection to the server.</li><li><strong>Client-side request serialization:</strong> The client serializes the request data.</li><li><strong>Client-side request transmission:</strong> The client sends the request to the server.</li><li><strong>Server-side request deserialization:</strong> The server deserializes the request data.</li><li><strong>Server-side request processing:</strong> The server processes the request.</li><li><strong>Server-side response serialization:</strong> The server serializes the response data.</li><li><strong>Server-side response transmission:</strong> The server sends the response to the client.</li><li><strong>Client-side response deserialization:</strong> The client deserializes the response data.</li></ol><h3>Basic Principles and Communication Types of gRPC</h3><p><strong>gRPC is based on a few basic principles:</strong></p><ul><li><strong>Interface First:</strong> gRPC services are defined in a proto file. This file defines the methods that the service exposes, as well as the data types that are used in those methods.</li><li><strong>Protocol Buffers:</strong> gRPC uses Protocol Buffers to serialize data. Protocol Buffers are a compact and efficient way to serialize data.</li><li><strong>HTTP/2:</strong> gRPC uses HTTP/2 to transmit data. HTTP/2 is a binary protocol that is more efficient than HTTP/1.1.</li></ul><p><strong>gRPC supports a variety of communication types, including:</strong></p><ul><li><strong>Unary:</strong> A unary RPC is a request-response RPC. The client sends a request to the server, and the server sends a response to the client.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*JfLyRdAlD73FcyZ9Qs2GpA.png" /><figcaption>unary</figcaption></figure><p><strong>Streaming:</strong> A streaming RPC is a request-stream or stream-response RPC. The client sends a request to the server, and the server sends a stream of responses to the client.</p><ul><li><strong>Client Streaming:</strong> The client streaming feature of gRPC allows clients to send multiple messages to the server in a streaming fashion.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*fZ7ykdnSyifPwJ4ym7Or6w.png" /><figcaption>client-streaming</figcaption></figure><ul><li><strong>Server Streaming:</strong> The server streaming feature of gRPC allows servers to send multiple messages to the client for a single request in a streaming manner.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*ybLZp9UN2CP2yeicr_F2Nw.png" /><figcaption>server-streaming</figcaption></figure><ul><li><strong>Bidirectional streaming:</strong> A bidirectional streaming RPC is a type of RPC where both the client and server can send streams of messages to each other asynchronously.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*NHbSN4vWJpHcrT8Inf2bhQ.png" /><figcaption>bi-directional</figcaption></figure><h3>Core Principles of gRPC</h3><p>gRPC is built on four core principles:</p><ol><li><strong>Protocol Buffers</strong>: gRPC utilizes Protocol Buffers (protobuf) as its interface definition language. Protocol Buffers provide a compact binary format that is more efficient to transmit and faster to parse compared to textual representations.</li><li><strong>Strongly-typed Contracts</strong>: gRPC enables you to define the service and message types in a protobuf file. This establishes a strongly-typed contract between the client and server, ensuring seamless communication and easy understanding of the exchanged data by both parties.</li><li><strong>Bi-directional Streaming</strong>: gRPC supports bi-directional streaming, allowing both the client and server to send and receive multiple messages over a single connection. This feature is especially useful for real-time communication and scenarios where continuous streams of data need to be exchanged by both parties.</li><li><strong>Language-Agnostic</strong>: gRPC is designed to be language-agnostic, meaning it can be used with various programming languages. The gRPC compiler generates client and server code in your preferred language, making it easy to integrate gRPC into your existing systems.</li></ol><h3>Key differences between REST, GraphQL, and gRPC</h3><p>REST, GraphQL, and gRPC are all popular ways to implement microservices architectures. However, there are some key differences between the three frameworks.</p><h3>REST</h3><p>REST, short for Representational State Transfer, is an architectural style that is commonly used in designing web services. RESTful APIs rely on HTTP methods to specify the actions that need to be taken on resources identified by URIs. As a result, RESTful APIs have become a prevalent and widely accepted method for creating web services.</p><ul><li><strong>Nature</strong>: Architectural style using HTTP methods for CRUD operations.</li><li><strong>Data Format</strong>: Typically JSON or XML.</li><li><strong>Flexibility</strong>: Clients can selectively request data, but may face over-fetching/under-fetching issues.</li><li><strong>Performance</strong>: Uses either HTTP/1.1 or HTTP/2; generally good but can be inefficient for large data.</li></ul><h3>GraphQL</h3><p>GraphQL is a specialized query language created for APIs that provides a great deal of flexibility. It enables clients to request only the data they need from the server, making it an incredibly effective tool for developing adaptable and efficient applications. By utilizing GraphQL APIs, developers can simplify the data retrieval process and significantly improve the performance of their applications.</p><ul><li><strong>Nature</strong>: A query language allowing clients to request only required data.</li><li><strong>Data Format</strong>: Typically JSON.</li><li><strong>Flexibility</strong>: High; clients can dictate exactly what they need.</li><li><strong>Performance</strong>: Uses HTTP/1.1; adaptable and efficient for diverse data needs.</li></ul><h3>gRPC</h3><p>gRPC is a Remote Procedure Call (RPC) framework that allows developers to build distributed systems easily. It utilizes HTTP/2 as a transport layer for fast and reliable data transmission, and Protocol Buffers for efficient data serialization. gRPC offers a range of features, including support for multiple programming languages, bi-directional streaming for real-time communication, flow control for efficient network utilization, and robust error handling for improved reliability. Its ability to create scalable, resilient, and maintainable distributed systems makes it a powerful tool for developers.</p><ul><li><strong>Nature</strong>: RPC framework focusing on service-to-service communication.</li><li><strong>Data Format</strong>: Protocol Buffers.</li><li><strong>Flexibility</strong>: Defined by the service’s protobuf file.</li><li><strong>Performance</strong>: Uses HTTP/2; excels in throughput and latency, especially for large data.</li></ul><h3>Pros and cons of using REST, GraphQL, and gRPC</h3><h3>REST</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*HDVLIJk5AeYae3tsJTL6aA.png" /><figcaption>REST — Pros vs Cons</figcaption></figure><h3>GraphQL</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*JfayhxE0hXtnqWsCjuRb-Q.png" /><figcaption>GraphQL — Pros vs Cons</figcaption></figure><h3>gRPC</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*LGV8NoyH9m2JRnxP1Cuq5g.png" /><figcaption>gRPC — Pros vs Cons</figcaption></figure><h3>Performance Comparison</h3><p>When comparing the performance of REST, GraphQL, and gRPC, several factors come into play, such as payload size, network latency, and the nature of the communication. Generally, gRPC outperforms REST and GraphQL in terms of throughput and latency due to its use of the compact binary format and the HTTP/2 protocol.</p><p>When evaluating communication protocols, performance is a paramount consideration. It determines the efficiency of data transfer, the scalability of your system, and the user experience. Let’s compare gRPC, REST, and GraphQL from a performance standpoint.</p><h3>1. Data Serialization and Size:</h3><ul><li><strong>REST</strong>: Typically uses JSON, which is textual and can be verbose for complex structures. This can lead to larger payloads.</li><li><strong>GraphQL</strong>: Also uses JSON. However, its strength lies in the ability for clients to request precisely what they need, potentially reducing the size of the response.</li><li><strong>gRPC</strong>: Uses Protocol Buffers, a binary format. It’s significantly more compact than JSON, leading to smaller payloads and faster serialization and deserialization.</li></ul><h3>2. Network Protocol Efficiency:</h3><ul><li><strong>REST</strong>: Can operate over HTTP/1.1 or HTTP/2. While HTTP/2 offers multiplexing and other improvements over its predecessor, REST doesn’t exploit all its benefits.</li><li><strong>GraphQL</strong>: Typically runs over HTTP/1.1 but can also use HTTP/2. Like REST, it doesn’t fully leverage HTTP/2’s features.</li><li><strong>gRPC</strong>: Exclusively uses HTTP/2, benefiting from its features like header compression, multiplexing, and prioritization.</li></ul><h3>3. Flexibility vs. Overhead:</h3><ul><li><strong>REST</strong>: While REST endpoints are fixed, the flexibility comes in the form of creating new endpoints. This can introduce overhead when many endpoints need to be maintained or if there’s a need to fetch data from multiple endpoints.</li><li><strong>GraphQL</strong>: Extremely flexible. Clients can specify exactly what they need in a single request. However, this flexibility can introduce complexity on the server side to resolve and optimize the queries.</li><li><strong>gRPC</strong>: Has fixed endpoints defined in the protobuf file, but the binary protocol and the ability to stream data efficiently can often outweigh the lack of flexibility in certain scenarios.</li></ul><h3>4. Real-time Data Handling:</h3><ul><li><strong>REST</strong>: Doesn’t natively support real-time data streams.</li><li><strong>GraphQL</strong>: Real-time capabilities can be achieved using subscriptions, but this requires additional tooling and setup.</li><li><strong>gRPC</strong>: Natively supports bidirectional streaming, making it a go-to for real-time applications.</li></ul><h3>5. Performance Metrics:</h3><ul><li><strong>REST</strong>: Good performance for general purposes. However, for applications with heavy data or real-time requirements, it might not be the best choice.</li><li><strong>GraphQL</strong>: Good performance, especially in scenarios where specific data needs are variable. Over-fetching and under-fetching are minimized.</li><li><strong>gRPC</strong>: Exceptional performance, particularly for high-throughput applications or services requiring real-time communication.</li></ul><p>However, it’s important to note that the performance of these protocols can vary depending on the specific use case. For example, if you have a simple CRUD (Create, Read, Update, Delete) application, REST might be sufficient. On the other hand, if you have real-time requirements or need to handle large amounts of data, gRPC could be a better choice.</p><h3>Summary of differences: gRPC vs. REST</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w-pC1PLM5mS-xaX4QOUGtg.png" /><figcaption>gRPC vs REST</figcaption></figure><h3>Key Differences gRPC By REST and GraphQL</h3><p><strong>REST</strong></p><p>REST (Representational State Transfer) is a widely adopted architectural style for designing networked applications. It uses standard HTTP methods like GET, POST, PUT, and DELETE to perform operations on resources identified by URLs (Uniform Resource Locators).</p><p>Some key differences between gRPC and REST include:</p><ul><li><strong>Data Format</strong>: REST typically uses textual representations like JSON or XML to transmit data, while gRPC uses Protocol Buffers, a compact binary format.</li><li><strong>Communication Protocol</strong>: REST uses HTTP/1.1 or HTTP/2 as the underlying communication protocol, while gRPC exclusively uses HTTP/2.</li><li><strong>Flexibility</strong>: REST allows clients to selectively request specific fields from a resource, while gRPC requires clients to retrieve the entire message.</li><li><strong>Strong Typing</strong>: gRPC enforces strong typing through the use of Protocol Buffers, while REST is more flexible and allows for looser data typing.</li></ul><p><strong>GraphQL</strong></p><p>GraphQL is a query language and runtime for APIs that offers a more efficient and flexible alternative to REST. It allows clients to specify the exact data requirements they need, reducing over-fetching and under-fetching of data.</p><p>Some key differences between gRPC and GraphQL include:</p><ul><li><strong>Communication Style</strong>: gRPC uses the remote procedure call (RPC) pattern, where clients invoke methods on the server, while GraphQL uses a query language to request specific data from the server.</li><li><strong>Data Fetching</strong>: gRPC retrieves entire messages, while GraphQL allows clients to specify the exact fields they need, reducing network overhead.</li><li><strong>Support for Real-time Data</strong>: gRPC natively supports bidirectional streaming, making it suitable for real-time communication. In contrast, GraphQL requires additional tooling to achieve real-time capabilities.</li></ul><h3>When to use gRPC</h3><p>gRPC is a good choice for microservices architectures where performance is critical. gRPC is also a good choice for applications that need to transmit large amounts of data.</p><p><strong>Here are some specific examples of when to use gRPC:</strong></p><ul><li><strong>To implement a real-time streaming service</strong>, such as a chat or video streaming service</li><li><strong>To implement a service that needs to transmit large amounts of data</strong>, such as a file transfer service</li><li><strong>To implement a service that needs to be very efficient, high-performance systems</strong>, such as a trading system</li><li><strong>To communicate Language-Agnostic services,</strong> such as microservices developed in different languages or applications using different platforms.</li></ul><h3>Best practices and techniques of gRPC</h3><p>Here are some best practices and techniques for gRPC integration, implementation, and development in microservice architectures:</p><ul><li><strong>Use a service mesh to manage gRPC traffic.</strong> A service mesh can help you to improve the performance, scalability, and reliability of your gRPC services.</li><li><strong>Use of Deadlines timeout and Cancellation to essential for reliable applications.</strong> This can avoid unnecessary server usage and thread blocking.</li><li><strong>Use a load balancer to distribute traffic across multiple gRPC servers.</strong> This can help to improve the performance and scalability of your gRPC services.</li><li><strong>Use a circuit breaker to prevent cascading failures.</strong> A circuit breaker can help to prevent a single failure from taking down your entire system.</li><li><strong>Use authentication and authorization to secure your gRPC APIs.</strong> This can help to protect your APIs from unauthorized access.</li><li><strong>Use monitoring and logging to track the performance and health of your gRPC APIs.</strong> This can help you to identify and troubleshoot problems with your APIs.</li></ul><p><strong>Additional tips for implementing gRPC in microservice architectures:</strong></p><ul><li><strong>Design your services to be independent and self-contained.</strong> This will make them easier to develop, test, and deploy.</li><li><strong>Use a consistent naming convention for your services and their methods.</strong> This will make it easier for developers to understand and use your APIs.</li><li><strong>Use a versioning scheme for your services and their methods.</strong> This will help you to manage changes to your APIs and to ensure that clients are compatible with the latest version of your APIs.</li><li><strong>Document your APIs thoroughly.</strong> This will help developers to understand how to use your APIs.</li></ul><h3>Service Definition and Using gRPC on the Client-side</h3><p>To define a gRPC service, you need to create a protobuf file that specifies the service and message types. Here’s an example of a simple protobuf file:</p><pre>syntax = &quot;proto3&quot;;<br><br>package myservice;<br>service MyService {<br>  rpc GetData(GetDataRequest) returns (GetDataResponse);<br>}<br>message GetDataRequest {<br>  string id = 1;<br>}<br>message GetDataResponse {<br>  string data = 1;<br>}</pre><p>In this example, we define a service called MyService with a single RPC method called GetData. The method takes a GetDataRequest message as input and returns a GetDataResponse message.</p><p>To use this service on the client-side, you need to generate client code using the gRPC compiler for your preferred programming language. Once the client code is generated, you can use it to invoke the RPC methods defined in the protobuf file.</p><p>Here’s an example of how you can use the generated client code in a .NET Core application:</p><pre>using Grpc.Core;<br>using MyService;<br><br>var channel = new Channel(&quot;localhost:50051&quot;, ChannelCredentials.Insecure);<br>var client = new MyServiceClient(channel);<br>var request = new GetDataRequest { Id = &quot;123&quot; };<br>var response = client.GetData(request);<br>Console.WriteLine(&quot;Data: &quot; + response.Data);</pre><p>In this example, we create a gRPC channel and client, then send a GetDataRequest to the server using the client&#39;s GetData method. The response is stored in a GetDataResponse object, and we can access the data returned by the server.</p><h3>Tutorial</h3><h3>gRPC — File Upload/Download Tutorial</h3><p>Now, I will explain how to create a gRPC client application using Nest.js and a gRPC server using .NET Core and how to perform file upload (client-streaming), download (server-streaming) and file-path query (unary) operations through these applications.</p><h3>1. gRPC Protocol Creation:</h3><p>First, we need to create the file.proto file that we will use in our service. This file defines the methods and message types of our service.</p><pre>syntax = &quot;proto3&quot;;<br><br>package file;<br>import &quot;google/protobuf/empty.proto&quot;; //such as return &quot;void&quot;<br>service FileService {<br>    rpc FileDownLoad (FileInfo) returns (stream BytesContent); //server streaming<br>    rpc FileUpLoad (stream BytesContent) returns(google.protobuf.Empty); //client streaming<br>    rpc GetFilePath (FileInfo) returns (FilePath); //unary<br>}<br>message FileInfo{<br>    string fileName = 1;<br>    string fileExtension = 2;<br>}<br>message BytesContent{<br>    int64 fileSize = 1;<br>    bytes buffer = 2;<br>    int32 readedByte = 3;<br>    FileInfo info = 4;<br>}<br>message FilePath{<br>    string filePath = 1;<br>}</pre><p>In the proto file above, we specify our functions to be communicated using gRPC with the <strong>“service”</strong> keyword by defining only their signatures as we do in the interfaces. The <strong>“protoc compiler”</strong> takes care of implementing the rest of the communication methods. Our first function is FileDownload, which uses the <strong>Server-Streaming</strong> method:</p><pre>rpc FileDownLoad (FileInfo) returns (stream BytesContent); //server streaming</pre><p>The FileDownload function above says that it will receive a request of type <strong>FileInfo</strong> and return <strong>BytesContent</strong> as a <strong>stream</strong>. After installing the necessary libraries on the server side, we do not need to do any development as I said above to use this communication method, we only need to implement business logic. <strong>(Server Streaming)</strong></p><pre>rpc FileUpLoad (stream BytesContent) returns(google.protobuf.Empty); //client stream</pre><p>The FileUpload function will return a response of type <strong>google.protobuf.Empty</strong> the <strong>BytesContent</strong> request, which is of type <strong>stream</strong>, made by the <strong>client</strong>. This data type can be considered as a <strong>“void”</strong> definition in protobuf <strong>(Client Streaming)</strong></p><pre>rpc GetFilePath (FileInfo) returns (FilePath); //unary</pre><p>Our last function, GetFilePath, declares that it will return the FilePath response to the request of type FileInfo by the client. <strong>(Unary)</strong></p><p>Now let’s examine <strong>message</strong> definitions:</p><pre>message FileInfo{<br>    string fileName = 1;<br>    string fileExtension = 2;<br>}</pre><p>Above we see a FileInfo element defined with the <strong>message</strong> keyword. We can liken this definition to defining special Request/Response types, or DTO structures with class/interface for Request/Response parameters in order for the client and server to stay in sync and communicate over the same type of data while developing REST API. In this way, the <strong>protoc compiler</strong> will define FileInfo in the relevant language and allow us to communicate over this data type.</p><p>In gRPC, fields are assigned a specific <strong>“Field Order”</strong> indicated by numbers next to the values. This ensures that data is sent in a specific order, with the <em>“fileName”</em> being sent first, followed by the <em>“fileExtension”</em>.</p><pre>message BytesContent{<br>    int64 fileSize = 1;<br>    bytes buffer = 2;<br>    int32 readedByte = 3;<br>    FileInfo info = 4;<br>}</pre><p>We can see that the <strong>FileInfo</strong> type is defined <strong>in the</strong> <strong>BytesContent</strong> data type. Yes, gRPC allows us to use other messages within a message type. In fact, if you need this data as an <strong>array</strong>, you can do it with the <strong>repeated</strong> keyword.</p><h3>2. Creating a .NET Core gRPC Server:</h3><p>2.1. Create the Project (you can also find it in Visual Studio by searching for “gRPC”):</p><pre>dotnet new grpc -o GrpcFileServer<br>cd GrpcFileServer</pre><p><strong>2.2.</strong> Add the file.proto file under the Protos folder and make sure that the .csproj file looks like the following:</p><pre>&lt;ItemGroup&gt;<br>  &lt;Protobuf Include=&quot;Protos\\file.proto&quot; GrpcServices=&quot;Server&quot; /&gt;<br>&lt;/ItemGroup&gt;</pre><p><strong>2.3.</strong> Create the FileService.cs file under the Services folder and replace its contents with the contents of the FileService.cs file provided above. This service file defines file upload, download, and file path import functions.</p><pre>using Grpc.Core;<br>using Google.Protobuf;<br>using Microsoft.AspNetCore.Hosting;<br>using System;<br>using System.IO;<br>using System.Threading.Tasks;<br><br>namespace GrpcFileServer.Services<br>{<br>    public class FileService : FileServiceBase<br>    {<br>        private readonly IWebHostEnvironment _webHostEnvironment;<br>        public FileService(IWebHostEnvironment webHostEnvironment)<br>        {<br>            _webHostEnvironment = webHostEnvironment;<br>        }<br>        public override async Task&lt;Empty&gt; FileUpLoad(IAsyncStreamReader&lt;BytesContent&gt; requestStream, ServerCallContext context)<br>        {<br>            // Handle the FileUpLoad operation<br>            // Read chunks of data from the client and process them<br>        }<br>        public override async Task FileDownLoad(FileInfo request, IServerStreamWriter&lt;BytesContent&gt; responseStream, ServerCallContext context)<br>        {<br>            // Handle the FileDownLoad operation<br>            // Send chunks of data to the client<br>        }<br>        public override Task&lt;FilePath&gt; GetFilePath(FileInfo request, ServerCallContext context)<br>        {<br>            // Handle the GetFilePath operation<br>            // Return file path<br>        }<br>    }<br>}</pre><p><strong>2.3.1. FileUpLoad Method</strong></p><pre>public override async Task&lt;Empty&gt; FileUpLoad(IAsyncStreamReader&lt;BytesContent&gt; requestStream, ServerCallContext context)<br>{<br>	string path = Path.Combine(_webHostEnvironment.WebRootPath, &quot;files&quot;);<br>	if (!Directory.Exists(path))<br>	    Directory.CreateDirectory(path);<br>	<br>	FileStream fileStream = null;<br>	<br>	try<br>	{<br>	    int count = 0;<br>	<br>	    //for uploaded rate<br>	    decimal chunkSize = 0;<br>	<br>	    while (await requestStream.MoveNext())<br>	    {<br>	        //Stream ilk başladığında(ilk adımda) yapılması gereken öncelikli işlevler<br>	        if (count++ == 0)<br>	        {<br>	            string filePath = $&quot;{path}/{requestStream.Current.Info.FileName}{requestStream.Current.Info.FileExtension}&quot;;<br>	            fileStream = new FileStream(filePath, FileMode.CreateNew);<br>	<br>	            //Gelecek dosya boyutu kadar alan tahsis ediliyor.<br>	            fileStream.SetLength(requestStream.Current.FileSize);<br>	        }<br>	<br>	        var buffer = requestStream.Current.Buffer.ToByteArray();<br>	<br>	        await fileStream.WriteAsync(buffer, 0, requestStream.Current.ReadedByte);<br>	<br>	        chunkSize += requestStream.Current.ReadedByte;<br>	        decimal uploadedRate = Math.Round((chunkSize * 100) / requestStream.Current.FileSize);<br>	        Console.WriteLine($&quot;{uploadedRate}%&quot;);<br>	    }<br>	    Console.WriteLine(&quot;Uploaded!&quot;);<br>	<br>	}<br>	catch (Exception ex)<br>	{<br>	    Console.WriteLine(&quot;Exception: &quot; + ex.ToString());<br>	}<br>	finally { <br>	    if (fileStream != null) { <br>	        await fileStream.DisposeAsync();<br>	        fileStream.Close();<br>	    } <br>	}<br>	return new Empty();<br>}</pre><p>You’ve implemented the <strong>FileUpLoad</strong> method, which is used for <strong>client-streaming</strong>. This method takes an <strong>IAsyncStreamReader&lt;BytesContent&gt;</strong> as a parameter, which allows the client to stream data to the server. This method handles file uploads.</p><ul><li>It creates a target directory to store uploaded files if it doesn’t exist.</li><li>It iterates through the incoming data stream and saves it to a file. The <strong>requestStream.MoveNext()</strong> method is used to check if there&#39;s more data coming.</li><li>The upload progress is logged to the console.</li><li>Finally, an <strong>Empty</strong> response is sent back to the client to indicate a successful upload.</li></ul><p><strong>2.3.2. FileDownload Method</strong></p><pre>public override async Task FileDownLoad(FileInfo request, IServerStreamWriter&lt;BytesContent&gt; responseStream, ServerCallContext context)<br>{<br>    string path = Path.Combine(_webHostEnvironment.WebRootPath, &quot;files&quot;);<br>    string filePath = $&quot;{path}/{request.FileName}{request.FileExtension}&quot;;<br>    try<br>    {<br>        bool isFileExist = File.Exists(filePath);<br>        if (!isFileExist) throw new FileNotFoundException(filePath);<br>        using FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);<br>        byte[] buffer = new byte[2048];<br>        BytesContent content = new BytesContent<br>        {<br>            FileSize = fileStream.Length,<br>            Info = new FileInfo { FileName = request.FileName + &quot;_gRPC_FileService&quot;, FileExtension = request.FileExtension },<br>            ReadedByte = 0<br>        };<br>        while ((content.ReadedByte = fileStream.Read(buffer, 0, buffer.Length)) &gt; 0)<br>        {<br>            //Okunan buffer&#39;ın stream edilebilmesi için &#39;message.proto&#39; dosyasındaki &#39;bytes&#39; türüne dönüştürülüyor.<br>            content.Buffer = ByteString.CopyFrom(buffer);<br>            await responseStream.WriteAsync(content);<br>        }<br>        fileStream.Close();<br>    }catch (Exception ex)<br>    {<br>        Console.WriteLine(ex.ToString());<br>    }<br>}</pre><p>The <strong>FileDownLoad</strong> method handles server-streaming. It takes a <strong>FileInfo</strong> as input and streams the file data back to the client.</p><ul><li>It constructs the path to the requested file and checks if the file exists.</li><li>If the file exists, it reads the file in chunks and sends these chunks to the client as <strong>BytesContent</strong> messages. The client can then reconstruct the file from these chunks.</li><li>If there are any exceptions, they are logged.</li></ul><p><strong>2.3.3. GetFilePath Method</strong></p><pre>public override Task&lt;FilePath&gt; GetFilePath(FileInfo request, ServerCallContext context)<br>{<br>  string path = Path.Combine(_webHostEnvironment.WebRootPath, &quot;files&quot;);<br>  string filePath = $&quot;{path}/{request.FileName}{request.FileExtension}&quot;;<br>  bool isFileExist = File.Exists(filePath);<br>  return Task.FromResult(isFileExist ? <br>      new FilePath() { FilePath_ = filePath }<br>      : throw new FileNotFoundException(filePath));<br>}</pre><p>The <strong>GetFilePath</strong> method is a unary RPC method. It takes a <strong>FileInfo</strong> and returns a <strong>FilePath</strong> indicating the path of the requested file.</p><ul><li>It constructs the path to the requested file and checks if the file exists.</li><li>If the file exists, it returns a <strong>FilePath</strong> with the file path.</li><li>If the file doesn’t exist, it throws a <strong>FileNotFoundException</strong>.</li></ul><h3>3. Creating a Nest.js gRPC Client:</h3><p><strong>3.1.</strong> Create a new Nest.js project:</p><pre>npx nest new GrpcFileClient<br>cd GrpcFileClient</pre><p><strong>3.1.1. Dependencies</strong></p><p>You start by importing the necessary dependencies:</p><ul><li><strong>Inject</strong> and <strong>Injectable</strong> are from <strong>@nestjs/common</strong> and are used for dependency injection.</li><li><strong>Observable</strong> and <strong>ReplaySubject</strong> are used for handling asynchronous operations from <strong>rxjs</strong>.</li><li><strong>ClientGrpc</strong> is from <strong>@nestjs/microservices</strong> and provides client functionalities for gRPC.</li></ul><p><strong>3.2.</strong> Add the file.proto file to your project and use this file to create the TypeScript service file with the protoc tool:</p><pre>protoc --plugin=protoc-gen-ts_proto=&quot;.\\node_modules\\.bin\\protoc-gen-ts_proto.cmd&quot; --ts_proto_out=nestJs=true,importSuffix=.js:. ./src/file.proto</pre><p>This command creates the files file_pb.js and file_grpc_pb.js.</p><p><strong>3.3.</strong> Create file.service.ts and file.controller.ts</p><pre>import {<br>  Controller,<br>  Get,<br>  Post,<br>  Req,<br>  UploadedFile,<br>  UseInterceptors,<br>} from &#39;@nestjs/common&#39;;<br>import { FileService } from &#39;./file.service&#39;;<br>import { FileInterceptor } from &#39;@nestjs/platform-express&#39;;<br>import { Request } from &#39;express&#39;;<br>import { FilePath } from &#39;src/file&#39;;<br><br>@Controller(&#39;file-controller&#39;)<br>export class FileController {<br>  constructor(private readonly fileService: FileService) {}<br>  @Get(&#39;download&#39;)<br>  async download(@Req() req: Request): Promise&lt;void&gt; {<br>    const { fileName, fileExtension } = req.query;<br>    const info = {<br>      fileName: fileName as string,<br>      fileExtension: fileExtension as string,<br>    };<br>    return this.fileService.fileDownLoad(info);<br>  }<br>  @Post(&#39;upload&#39;)<br>  @UseInterceptors(FileInterceptor(&#39;file&#39;))<br>  async uploadFile(@UploadedFile() file: Express.Multer.File) {<br>    await this.fileService.fileUpLoad(file);<br>  }<br>  @Get(&#39;get-file-path&#39;)<br>  async getFilePath(@Req() req: Request): Promise&lt;FilePath&gt; {<br>    const { fileName, fileExtension } = req.query;<br>    const info = {<br>      fileName: fileName as string,<br>      fileExtension: fileExtension as string,<br>    };<br>    return this.fileService.getFilePath(info);<br>  }<br>}</pre><p><strong>3.3.1.</strong> <strong>Constructor and Initialization</strong> You create a class called <strong>FileService</strong> and use the <strong>@Inject</strong> decorator to inject the gRPC client instance, which was configured with the name &quot;FILE_PACKAGE&quot; during the client setup.</p><ul><li>In the <strong>onModuleInit</strong> method, you initialize the gRPC client and obtain the <strong>FileServiceClient</strong> instance for making gRPC calls.</li></ul><pre>/* eslint-disable prettier/prettier */<br>import { Inject, Injectable } from &#39;@nestjs/common&#39;;<br>import { Observable, ReplaySubject } from &#39;rxjs&#39;;<br>import { ClientGrpc } from &#39;@nestjs/microservices&#39;;<br>import { FileServiceClient, FILE_SERVICE_NAME, FileInfo, BytesContent, FilePath } from &#39;../file&#39;;<br>import { writeFile } from &#39;fs&#39;;<br><br>@Injectable()<br>export class FileService {<br>  private fileService;<br>  constructor(<br>    @Inject(&quot;FILE_PACKAGE&quot;)<br>    private grpcClient: ClientGrpc,<br>  ) {}<br>  onModuleInit() {<br>    this.fileService = this.grpcClient.getService&lt;FileServiceClient&gt;(FILE_SERVICE_NAME);<br>  }<br>}</pre><p><strong>3.3.2 File Download</strong></p><pre>async fileDownLoad(info: FileInfo): Promise&lt;void&gt; {<br>    const fileStream: Observable&lt;BytesContent&gt; =<br>      this.fileService.fileDownLoad(info);<br>// create file from stream<br>    const fileData: BytesContent = {<br>      buffer: Buffer.alloc(0),<br>      fileSize: 0,<br>      info: {<br>        fileName: &#39;&#39;,<br>        fileExtension: &#39;&#39;,<br>      },<br>      readedByte: 0,<br>    };<br>    // write file when stream is completed<br>    await new Promise((resolve) =&gt; {<br>      fileStream.subscribe({<br>        next: (resFile: BytesContent) =&gt; {<br>          fileData.buffer = Buffer.concat([fileData.buffer, resFile.buffer]);<br>          fileData.fileSize = resFile.fileSize;<br>          fileData.info = resFile.info;<br>          fileData.readedByte = resFile.readedByte;<br>        },<br>        error: (err) =&gt; {<br>          console.error(err);<br>        },<br>        complete: () =&gt; {<br>          writeFile(<br>            `${fileData.info!.fileName}${fileData.info!.fileExtension}`,<br>            fileData.buffer,<br>            (err) =&gt; {<br>              if (err) {<br>                console.error(err);<br>                return;<br>              }<br>              console.log(<br>                `${fileData.info!.fileName}${<br>                  fileData.info!.fileExtension<br>                } was saved successfully.`,<br>              );<br>            },<br>          );<br>        },<br>      });<br>      resolve(fileData);<br>    });<br>  }</pre><p>You implement the <strong>fileDownLoad</strong> method, which is responsible for downloading files from the server using server-streaming.</p><ul><li>It first gets an <strong>Observable</strong> of <strong>BytesContent</strong> by calling <strong>this.fileService.fileDownLoad(info)</strong>. This observable represents the server&#39;s response.</li><li>The method then creates an empty <strong>fileData</strong> object to collect the downloaded file.</li><li>A promise is used to handle the stream subscription.</li><li>Inside the subscription, the method listens for new chunks of data in the stream and concatenates them to <strong>fileData.buffer</strong>.</li><li>When the stream completes, it writes the downloaded file to the local filesystem.</li></ul><p><strong>3.3.3. File Upload</strong></p><pre>async fileUpLoad(file: Express.Multer.File): Promise&lt;void&gt; {<br>    const subject = new ReplaySubject&lt;BytesContent&gt;();<br>    const chunkSize = 2048;  // Chunk size set to 2 KB<br>    const totalChunks = Math.ceil(file.size / chunkSize);<br>    const fileStream = file.buffer;<br>    const upload = this.fileService.fileUpLoad(subject).subscribe();<br><br>    for (let i = 0; i &lt; totalChunks; i++) {<br>      const start = i * chunkSize;<br>      const end = Math.min(start + chunkSize, file.size);<br>      const chunk = fileStream.subarray(start, end);<br>      const content: BytesContent = {<br>        buffer: chunk,<br>        fileSize: file.size,<br>        info: {<br>          fileName: file.originalname.split(&#39;.&#39;).shift()!,<br>          fileExtension: &quot;.&quot; + file.originalname.split(&#39;.&#39;).pop()!,<br>        },<br>        readedByte: chunk.length,<br>      };<br>      // ReplaySubject is used to send each chunk to the server<br>      subject.next(content);<br>    }<br>    // Complete the stream once all chunks have been sent<br>    subject.complete();<br>    // Optionally, handle the response or errors from the server<br>    upload.unsubscribe();<br>  }</pre><p>The <strong>fileUpLoad</strong> method is responsible for uploading files to the server using client-streaming.</p><ul><li>It creates a <strong>ReplaySubject&lt;BytesContent&gt;</strong> to send chunks of data to the server.</li><li>The method calculates the chunk size and total chunks to upload the file in manageable parts.</li><li>It iterates through the file, sending each chunk to the server using the <strong>subject.next(content)</strong> method.</li><li>After all chunks are sent, the stream is completed with <strong>subject.complete()</strong>.</li></ul><p><strong>3.3.4. GetFilePath</strong></p><pre>getFilePath(info: FileInfo): FilePath {<br>  return this.fileService.getFilePath(info);<br>}</pre><p>The <strong>getFilePath</strong> method is a simple unary RPC call. It takes a <strong>FileInfo</strong> and returns a <strong>FilePath</strong> indicating the path of the requested file.</p><p><strong>3.4.</strong> Configure the gRPC client configuration in the main.ts file:</p><pre>async function bootstrap() {<br>  const app = await NestFactory.createMicroservice&lt;MicroserviceOptions&gt;(AppModule, {<br>    transport: Transport.GRPC,<br>    options: {<br>      url: &#39;localhost:5000&#39;, //grpc server&#39;s url<br>      package: &#39;file&#39;,<br>      protoPath: join(__dirname, &#39;./file.proto&#39;),<br>    },<br>  });<br>  app.listen(() =&gt; console.log(&#39;Microservice is listening&#39;));<br>}<br>bootstrap();</pre><h3>4. Test</h3><p>And it’s finally done! Now you can excitedly launch Nest.js gRPC client and .NET core gRPC server and test file uploads and downloads.</p><p><strong>grpc client:</strong></p><p><a href="https://github.com/haliltokszz/gRPC-client-FileService">https://github.com/haliltokszz/gRPC-client-FileService</a></p><p><strong>grpc server:</strong></p><p><a href="https://github.com/haliltokszz/gRPC-server-FileService">https://github.com/haliltokszz/gRPC-server-FileService</a></p><h3>Conclusion</h3><p>gRPC is a powerful communication framework that offers high-performance and efficient communication between services. It provides a modern alternative to traditional communication protocols like REST or GraphQL, with features like compact binary encoding, bidirectional streaming, and language-agnostic support. By understanding the core principles of gRPC and comparing them to other protocols, developers can make informed decisions on when and how to use gRPC effectively in their applications.</p><h3>References</h3><ol><li><a href="https://grpc.io/docs/what-is-grpc/introduction/">Introduction to gRPC | gRPC</a></li><li><a href="https://blog.bytebytego.com/p/ep32-how-does-grpc-work">How does gRPC work?</a></li><li><a href="https://aws.amazon.com/tr/compare/the-difference-between-grpc-and-rest/">The Difference Between gRPC and REST</a></li><li><a href="https://cloud.google.com/blog/products/api-management/understanding-grpc-openapi-and-rest-and-when-to-use-them">Understanding gRPC, OpenAPI, and REST and when to use them</a></li><li><a href="https://www.designgurus.io/blog/REST-GraphQL-gRPC-system-design">REST, GraphQL, and gRPC: A System Design Comparison</a></li><li><a href="https://learn.microsoft.com/en-US/dotnet/architecture/cloud-native/grpc">gRPC on .NET Core</a></li><li><a href="https://medium.com/deliveryherotechhub/grpc-nedir-ve-nas%C4%B1l-uygulan%C4%B1r-microservice-mimarisi-ile-grpc-9f1dc0847475">gRPC Nedir ve Nasıl Uygulanır? (Microservice Mimarisi ile gRPC)</a></li><li><a href="https://www.gencayyildiz.com/blog/grpc-file-streaming-nasil-gerceklestirilir/">gRPC — File Streaming Nasıl Gerçekleştirilir? — Yazılım Mimarileri ve Tasarım Desenleri Üzerine (gencayyildiz.com)</a></li><li><a href="https://www.gencayyildiz.com/blog/grpc-nedir-ne-amacla-ve-nasil-kullanilir/">gRPC Nedir, Ne Amaçla ve Nasıl Kullanılır?</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e6e65ff9f71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Yazılım Yaşam-Döngü Modelleri]]></title>
            <link>https://medium.com/@haliltoksz/yaz%C4%B1l%C4%B1m-ya%C5%9Fam-d%C3%B6ng%C3%BC-modelleri-d2e8696ab50e?source=rss-d6a539034905------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2e8696ab50e</guid>
            <dc:creator><![CDATA[Halil Toksöz]]></dc:creator>
            <pubDate>Fri, 08 Mar 2019 17:00:32 GMT</pubDate>
            <atom:updated>2019-03-08T17:00:32.145Z</atom:updated>
            <content:encoded><![CDATA[<p>Yazılım yaşam-döngüsü, bir yazılım ürününün hem üretilirken hem de kullanım süreci boyunca geçirdiği adımlara verilen addır.</p><p>Yazılım sadece kodlamadan oluşmaz. Öncelikle ortaya konulacak ürünün gereksinimleri çıkarılmalı, maliyetleri hesaplanmalı, projenin planlanması yapılmalıdır. Bu yapılan adımları temel yazılım geliştirme aşamalarının ilki olan “Planlama” aşamasında gerçekleştirilir. Sonrasında ise sırasıyla: <strong>Analiz, Tasarım, Gerçekleştirim </strong>ve<strong> Bakım</strong> aşamaları gelir.</p><p><strong>Analiz aşamasında</strong> sistemin işlevleri ve gereksinimleri açığa kavuşturulur, doküman yazılır. Bu aşamada kritik rol oynayan olay ise<strong> “Müşteri-Yazılımcı” ilişkisidir.</strong> Müşteri her zaman size ne istediğini anlatmaz veya anlatamaz. Böyle durumlarda müşteri ile olan iletişiminizin kuvvetli olması sizi muhtemel hatalardan, eksik gereksinimlerden, proje teslim tarihinin uzamasından ve maliyetin artması gibi konulardan kurtaracaktır.</p><p><strong>Tasarım aşamasına</strong> gereksinimlerin tamamlanması ile geçilir. Müşterinin gereksinim ve isteklerini karşılamak için yazılım ürünü tasarlanmaya başlanır. İki tür tasarımdan bahsetmek mümkündür:<strong> “Üst Seviye ve Mimari Tasarım”</strong>, <strong>“Detaylı Tasarım”</strong>. Mimari tasarım sistemin yapısı ile ilgilenir. Detaylı tasarım ise yazılımı içeren bileşenler ve bunların ayrıntılarıyla ilgilenir. Tasarım esnasında projenin ara yüzü, özellikleri tüm ihtiyaç ve isteklere göre belirlenir. “Problem nasıl çözülür?” sorusuna yanıt aranır. Problemin nasıl çözüleceği kısmında birçok teknik vardır. Bunlardan en önemlisi “Soyutlama” tekniğidir. Bu teknikte problemin basitleştirilip en önemli kısımlarına odaklanmak asıl hedeftir.</p><p><strong>Gerçekleştirim aşaması</strong> ise yazılımı kodlama ve test etme işlemlerini içerir. Tasarımın tamamlanmasından sonra müşteriye el ile tutulur bir şey vermek için kodlamaya ve hatasız bir şekilde istekleri, ihtiyaçları gerçekleştirdiğini görmek için ise teste başlanır.</p><p>Testleri de tamamlanan yazılımın artık <strong>“Teslim-Bakım”</strong> süreci başlamıştır. Müşteriye teslim edilen ürünün işi bitmez, ayrıca bakım yapılması gerekir.</p><p>Bu temel aşamaların farklı yorumlanması, farklı tekniklerle birleştirilmesiyle ortaya çok fazla süreç ve yöntem çıkmıştır. Her bir süreç modeli temelde bu yaşam döngüsünü takip eder. Yazılım süreç modellerine bir göz atmak gerekirse:</p><h4>Kodla-Düzelt Modeli</h4><p>Direkt olarak yazılım geliştirilmeye başlanır ve istenilen seviyeye gelene kadar sürekli geliştirilir. Çok küçük programlarda kullanılabilir. Dokümantasyon olmadığı için bakım safhası çok zordur. Yazılım geliştirmek için en kolay ama en pahalı yoldur.</p><h4>Araştırma Tabanlı Model</h4><p>Bu model projelerde, yarışmalarda kullanılan bir modeldir. Proje sonucu belli olmadığından maliyet hesabı yapmak mümkün değildir. Sınırlı sayıda üretim olur. Yap-At proje olarak da nitelendirilebilir.</p><h4>Gelişigüzel Model</h4><p>Bu yöntemi bir model olarak adlandırmak doğru değildir. Herhangi bir yöntem ve model gözetmeksizin yapılır. Bu yüzden takip edilebilirliği ve bakımı oldukça zordur. 1960’larda kullanılan bu yöntem, genellikle tek kişinin üretim yaptığı basit programlama içeren yöntemdir.</p><h4>Barok Modeli</h4><p>1970’li yıllarda uygulanan bu yöntem yazılım yaşam-döngüsü temel adımlarının doğrusal bir biçimde uygulandığı modeldir. Bu modelde dokümantasyon ayrı bir süreç olarak gerçekleştirim aşamasından sonra ele alınır ve aşamalar arasındaki geri dönüşler tanımlanmamıştır.</p><p>Günümüzde dokümantasyon her aşamada kullanıldığından, gerçekleştirim evresine bu modelde çok ağırlık verildiğinden kullanımdan çıkmıştır.</p><h4><strong>Çağlayan (Şelale) Modeli</strong></h4><p>Geleneksel yazılım geliştirme modeli olarak da bilinen Çağlayan modeli, geçmişte en popüler yazılım geliştirme modeli olarak görülmüştür. En temel, en eski ve en tanınmış modeldir. İşlemler aşama aşama ele alınır ve her aşamanın en az bir kez tekrar edilmesi gerekir. Bir aşama bitmeden sonraki aşamaya geçilmez.</p><p>Barok modelinden farklı olarak dokümantasyon farklı bir süreç olarak değil üretimin her aşamasında olması gereken doğal bir parça olarak görülmüştür. Ayrıca yine Barok modelinden farklı olarak önceki aşamalara nasıl geri dönüleceği de bu yöntemde tanımlanmıştır.</p><p>Gereksinimlerin çok iyi tanımlanması yapılır. Sonrasında sistem ve yazılım tasarımı gerçekleştirilirken tüm gereksinimlerin karşılanması istendiğinden analiz ve tasarım aşamaları çok uzun sürmektedir. Bu süre içerisinde ise yazılımın gereksinimleri değişeceğinden, kullanıcı ile iletişimin yüksek olmadığından geri dönüşlerin çok geç yapılmasıyla birlikte maliyetlerin çok artması bu yöntemin en büyük dezavantajlarından biridir.</p><h4>V Süreç Modeli</h4><p>Bu modelin uygulanabileceği projeler için belirsizlik az, iş tanımlarının kesinlikle belirgin olması gerekir. V süreç modelinde kullanıcının sistem gelişiminde katkısı vardır. Temel çıktıları: Kullanıcı Modeli, Mimari Model, Gerçekleştirim Modeli’ dir.</p><p>Bu modelin avantajları takibi ve kullanımı kolay olmasıdır. Ama risk çözümleme ve tekrar olmaması modelin dezavantajlarındandır.</p><h4>Helezonik (Spiral) Model</h4><p>Helezonik modelin en çok önem verdiği konu risk analizi ve prototip üretmektir. Her fazda bir prototip üretilir ve risk analizi yapılır.</p><p>Yinelemeli artımsal bir yaklaşım vardır. Her döngü sonunda tekrardan planlama yapılarak gereksinim ve istekler yeniden hesaplanır. Modelin geçirdiği safhalar:<strong> Planlama, Risk Analizi, Üretim, Kullanıcı Değerlendirmesi</strong>’ dir.</p><p><strong>Planlama aşamasında</strong> üretilecek prototip için planlama, amaç belirleme, bir önceki adımda üretilen prototip ile bütünleştirme yapılır.</p><p><strong>Risk analizi</strong> kısmında riskler belirlenir.</p><p><strong>Üretimde</strong> bir prototip elde edilir.</p><p><strong>Kullanıcı değerlendirmesi</strong> aşamasında da prototipin kullanıcı tarafından deneme ve değerlendirmeleri yapılır.</p><p>Bu modelin bazı avantajları vardır. Her döngüde prototip üretilip üretilen prototip kullanıcı tarafından değerlendirildiği için kullanıcı katkısı ön plandadır ve buna bağlı olarak hata riski düşer. Proje boyunca prototip üretildiği için de yöneticilerin projeyi takip edebilmesi kolaylaşır. Yazılımcılar ise Çağlayan modeline zıt olarak projenin kodlanmasına ve sınanmasına daha erken başlarlar. Dezavantajları ise küçük ve az riskli projeler için pahalı bir modeldir. Kompleks yapıya sahiptir.</p><h4>Evrimsel Geliştirme Süreç Modeli</h4><p>Müşterinin ne istediğini bilmediği zamanlarda kullanılan bu model ilk tam ölçekli modeldir. Kaba gereksinim ve tanımlamalarla bir ürün(evrim) oluşturulur. İlk sürümden yola çıkarak tanımlamalar daha net anlaşılır ve sonraki sürümler daha başarılı istenilen ürüne evrilir.</p><p>Başarısı ilk evrimin başarısına bağımlı haldedir. Tüm aşamalarda üretilen ürünler, üretildikleri yer için işlevseldir. Dezavantajı ise değişiklik denetimine sahip olmaması ve gereksinimlerin sürekli değişebilmesidir.</p><h4>Artımsal Geliştirme Süreç Modeli</h4><p>Proje tek seferde teslim edilmez. Kullanıcı gereksinimleri önceliklerine göre parçalanır ve bir parçanın geliştirilmesi başlandığında diğer gereksinimler ele alınmaz. Olası gereksinim değişiklikleri sonraki teslimlere bırakılır. Üretilen her yazılım sürümü birbirini kapsar ve işlevselliği giderek artar. Kullanım ve üretim eş zamanlı yürütülür.</p><p>Bu modelde de kullanıcıya ara ürün verildiğinden hata riski çok düşer ve her ara ürün birbirini kapsadığı için öncelikli gereksinimler daha çok test edilir.</p><h3>ÇEVİK YAZILIM</h3><p>Çevik yazılım geliştirme metotları müşteriye ürünü daha hızlı teslim etme ve isteklere hızlı yanıt verebilme isteğinden doğmuştur. Verimliliği yüksek, hata oranı düşük, hızlı ve ucuz çözümler sağlamaktadır.</p><p>Projenin büyüklüğü ne olursa olsun küçük yinelemelere ayrılır ve her yineleme başlı başına bir proje gibi ele alınır. Çevik yazılım geliştirmede yazılımı geliştirmek için aktiviteler tekrarlı şekilde uygulandığından yazılım, yavaş yavaş, ihtiyaçları anlaya anlaya, değişime açık ve kaliteli bir tarzda geliştirilir.</p><p>Her yineleme 2–4 hafta sürecek şekilde planlanır ve yineleme sonlarında müşteriye bilgi verilir. Böylece müşteri memnuniyeti artmış olur. Projenin küçük parçalara ayrılması da geriye dönük hataların düzeltilmesini kolaylaştırmaktadır.</p><p>Bu metotta yazılımcının motivasyonu yüksek seviyede olur. Kalite, üretkenlik ve başarı artar, maliyet düşer. Çevik yazılım geliştirme metotları temeli aynı fakat pratiği farklı metodolojilere ayrılmıştır.</p><h4>EXTREME PROGRAMMİNG (XP)</h4><p>Kent Beck tarafından 1999 yılında ortaya çıkmış kolay, grup içi iletişime önem veren, daha fazla geri dönüşe imkan veren yazılım geliştirme disiplinidir. Yazılım geliştirme sürecinin en temel, en önemli ve final çıktısı ya da ürünü çalıştırılabilir kod olduğundan, XP metodolojisi sürecin en başından itibaren çalıştırılabilir kodu sürecin merkezinde tutmaktadır. Bu yüzden bu metodolojinin adı XP’dir. Xp temelde 4 değeri baz alır. Bunlar: İletişim, Basitlik, Geri Bildirim, Cesaret. 12 tane XP pratiği vardır:</p><h4>Planlama Oyunu</h4><p>Müşterinin de bulunduğu toplantıda belirlenen yinelemenin ne kadar süre içerisinde yapılabileceğinin tahmin edilmesidir.</p><h4>Ekipte Müşteri</h4><p>Müşteri temsilcisi yazılımın geliştirilme sürecinde yazılım ekibiyle birlikte bulunur. Böylece yazılımcının ihtiyaç duyduğu bilgilere çok kısa sürede erişilir.</p><h4>Önce Test</h4><p>Kod yazılımdan önce test programı yazılarak mevcut sorunların daha erken çıkması sağlanır, daha güvenli yazılım gerçekleştirilmeye çalışılır.</p><h4>Basit Tasarım</h4><p>Müşterinin gereksinimlerini karşılayacak en basit tasarım gerçekleştirilir, gerektiğinde refactor edilecek şekilde tasarlanır.</p><h4>İkili Programlama</h4><p>İkili takımlar halinde çalışılır. İki kişi farklı düşündüğünden sorunlar daha hızlı çözüldüğü gibi kalite de artar.</p><h4>Sürekli Entegrasyon</h4><p>Sistem değişiklikleri ve yeni bileşenler hemen sisteme entegre edilir. Böylece uyumluluk sorunları erkenden önlenir ve her yazılımcının sistem üzerindeki değişiklikleri görmeleri sağlanır.</p><h4>Kısa Aralıklarla Yeni Sürüm</h4><p>2–4 haftalık sürümler oluşturulur. En önemli gereksinimler ilk sürümlerde karşılanır. Bu sayede hem müşteriler çalışır durumdaki programdan faydalanabilir hem de yeni sürümü inceleyerek gereksinimlerin karşılanıp karşılanmadığını, mevcut hataları bulup yazılımcıya bildirebilir.</p><h4>Refactoring (Yeniden Yapılandırma)</h4><p>Devamlı iyileştirme yapılmasını sağlar. Tasarım hataları yazılımı emekliye ayıracak kadar büyük olabilir, bunu önleyerek hataların hemen giderilmesini sağlar. Yapılan değişikliklerin sisteme olan yan etkileri de erken fark edilmiş olur.</p><h4>Ortak Kod</h4><p>Tüm takım her şeyi bilir. Bu her kod parçasının herhangi bir yazılımcı tarafından gerekli durumlarda değiştirilebilmesine olanak tanır.</p><h4>Metafor</h4><p>Basitleştirilmiş sistem mimarisidir. Projenin nasıl bir işlevi olacağını ekibin gözünde canlandıracak tanımlar, nesneler ya da resimlerdir.</p><h4>Kodlama Standardı</h4><p>Kodun anlaşılabilmesi ve okunabilmesi için ekip tarafından tanımlanmış kodlama standardı olmalıdır.</p><h4>Haftada 40 Saat</h4><p>Haftada 40, günde 8 saatlik çalışma süresinde işlerin gerçekleştirilmesi planlanır. Bu sürenin üstünde çalışmak verimi arttırmaz hatta yapılan hatalarda artış meydana gelir.</p><h3>SCRUM</h3><p>Scrum adı, Rugby sporundaki hücum taktiğinin adıdır. Sadece yazılım geliştirmede değil, hayatın her alanında uygulanabilir. Scrum ilk bakışta metodoloji gibi adım adım uyulması gereken kurallara sahip gibi görünse de aslında esnek bir çerçeve, yönetim sürecidir.</p><p>Bu çerçeve içinde aslında istenen deneysel davranıştır. Temelinde deneycilik yatan Scrum, sürekli kontrol sağlanabilmesi ve özellikle de risklerin kontrol altında tutulabilmesi için artımsal bir yaklaşım benimser. Bu artımları sağlayan yinelemelere <strong>sprint</strong> denir. Bir sprintin tamamlanması 30 günden fazla sürmez ve günlük 15 dakikalık toplantılarla iş takibi yapılır. Her sprint sonunda müşteriye çalışan bir sürüm elde edilir.</p><p>Sprintler, <strong>Scrum takımı</strong> ile gerçekleştirilir. Müşteri ile <strong>ürün gereksinimleri(product backlog)</strong> hakkında anlaşan <strong>ürün yöneticisi/sahibi(Product Owner)</strong>, Scrum takımı tarafından ortaya çıkarılan ürünlerin mevcut değerini maksimuma çıkarmaktan sorumlu kişidir. Product Owner, projeyi şekillendirip hangi işlerin öncelikli olduğuna karar verir ve sprintleri ona göre hazırlar. Scrum takımı ise bir <strong>Scrum Master(Scrum Lideri)</strong> ile birlikte en fazla 9 kişilik takımdır. Scrum Master ekibin <strong>yöneticisi değildir</strong>. Scrum’ ı çok iyi bilen, ekibe yol gösteren kişidir. Scrum Master geliştirme ekibindeki bir kişi de olabilir. Geliştirme ekibinde ise herkes sadece geliştiricidir. Scrum takımında alt takım ve roller bulunmaz. Böylece birbirine karşı açık, saygılı, eşit davranan ve adını alığı tüm takımın birlikte gol atmaya çalıştığı Rugby sporunun hücum taktiği gibi ortak hedefe bir bütün olarak yürünür. Böyle bir takımın oluşması, benimsenmiş Scrum Teorisi ve değerlerinin sonucudur.</p><p>Scrum teoresini destekleyen üç temel ayak vardır: Şeffaflık, gözlem ve adaptasyon. Şeffaflık ortak dil ve kuralları, izlenebilirliği esas alır. Gözlem ve adaptasyon için ise Scrum etkinlikleri gerekir. Bu etkinlikler: <strong>Günlük Scrum, Sprint Planlama, Sprint Değerlendirme </strong>ve<strong> Sprint Retrospektifi</strong>’ dir.</p><p>Sprint, <strong>Sprint Planlama</strong> etkinliği ile başlar. “Ne?” ve “Nasıl?” sorularına cevap aranır. Takım tarafından ürün için ne yapılacağı ve nasıl yapılacağı belirlenir.</p><p>Scrum Takımı her sabah 15 dakikalık <strong>Günlük Scrum</strong> etkinliğinde neler yaptıklarını, neler yapacaklarını ve karşılaştıkları sorunları birbirleri ile paylaşır.</p><p>Sprint sonunda üretilen artırımın sunulduğu <strong>Sprint Değerlendirilmesi</strong> yapılır. Scrum takımı sprinti kontrol eder, ortaya konulan işi gösterir ve soruları cevaplar. Ürün sahibi gereksinimlerin karşılanıp karşılanmadığını açıklar ve gerekiyorsa gereksinimler güncellenir.</p><p>Sprint Değerlendirme etkinliğinden sonra<strong> Sprint Retrospektif</strong> etkinliği yapılır. Sadece Scrum takımının katıldığı bu etkinlikte takım kendini inceler, denetler ve gözlemler. Neleri iyi yaptıklarını, nelerin geliştirilebileceğini tartışır ve geliştirilebilecek noktaları belirleyip aksiyon planı hazırlar. İyileşmek ve gelişmek için belirlenen bu maddeler yeni başlanacak Sprint’ in iş listesine eklenir.</p><p>Günümüzde yaklaşık %90 oranında kullanılan Scrum, müşteriye sürekli çalışan sürüm verilerek geri dönüşlerin daha hızlı olması, değişliklerin kolayca gerçekleştirilebilmesi, eşit ve sorumluluk sahibi bireylerden oluşan takım duygusu, maliyeti ve hata risklerini azaltması, her gün ne kadar iş yapıldığını ve ne kadar iş kaldığının şeffaf bir şekilde görülebilmesi, daha az süreyle daha çok iş yapılması gibi nedenlerden dolayı büyük-küçük her firma ve hemen hemen her proje tarafından kullanılıyor.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2e8696ab50e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>