<?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 Murat Gunay on Medium]]></title>
        <description><![CDATA[Stories by Murat Gunay on Medium]]></description>
        <link>https://medium.com/@muratgny06?source=rss-db48bf9511f3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Vechp84LJtpJdGlhQYYhfg.jpeg</url>
            <title>Stories by Murat Gunay on Medium</title>
            <link>https://medium.com/@muratgny06?source=rss-db48bf9511f3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:09:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muratgny06/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[Transitioning to Unified State Management: Refactoring a ViewModel and Screen]]></title>
            <link>https://muratgny06.medium.com/transitioning-to-unified-state-management-refactoring-a-daynote-viewmodel-and-screen-706a750b4bb4?source=rss-db48bf9511f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/706a750b4bb4</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[state-management]]></category>
            <dc:creator><![CDATA[Murat Gunay]]></dc:creator>
            <pubDate>Tue, 10 Dec 2024 13:10:20 GMT</pubDate>
            <atom:updated>2024-12-11T04:38:04.847Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m2qHlZVPHWfpClxcw97ITA.jpeg" /></figure><p>In modern app development, managing UI state in a clean and scalable way is critical. Many developers start with a non-unified approach where individual fields (like posts, comments, isLiked) are stored as separate LiveData properties in the ViewModel. While this works for simple scenarios, it often leads to duplication, bugs, and difficulty testing as the application grows.</p><p>In this article, we’ll refactor a non-unified stateful design into a unified state design using the ViewModel and its corresponding screen as an example. We&#39;ll focus on <strong>cleaning up the ViewModel, structuring the UI state, and simplifying the screen’s logic</strong>.</p><h3>Why Unified State Design?</h3><p>Unified state design organizes all the state variables into a single object, often called UiState. The benefits include:</p><ol><li><strong>Single Source of Truth</strong>: All UI-related data is stored in one place.</li><li><strong>Simpler State Management</strong>: Avoids inconsistent states or redundant LiveData updates.</li><li><strong>Easier Testing</strong>: You can test the ViewModel by simply observing the UiState.</li><li><strong>Improved Readability</strong>: Reduces the mental overhead of tracking multiple LiveData properties.</li></ol><h3>Step 1: The Initial Non-Unified ViewModel</h3><p>Here’s what the original ViewDaynoteViewModel might look like:</p><pre>class ViewDaynoteViewModel : ViewModel() {<br>    private val _daynote = MutableLiveData&lt;Daynote?&gt;()<br>    val daynote: LiveData&lt;Daynote?&gt; = _daynote<br><br>    private val _userPreviewData = MutableLiveData&lt;UserPreview?&gt;()<br>    val userPreviewData: LiveData&lt;UserPreview?&gt; = _userPreviewData<br><br>    private val _isDaynoteLiked = MutableLiveData&lt;Boolean&gt;()<br>    val isDaynoteLiked: LiveData&lt;Boolean&gt; = _isDaynoteLiked<br><br>    private val _commentList = MutableLiveData&lt;List&lt;Comment&gt;&gt;()<br>    val commentList: LiveData&lt;List&lt;Comment&gt;&gt; = _commentList<br><br>    private val _commentText = MutableLiveData&lt;String&gt;()<br>    val commentText: LiveData&lt;String&gt; = _commentText<br><br>    private val _isCommentSectionVisible = MutableLiveData&lt;Boolean&gt;()<br>    val isCommentSectionVisible: LiveData&lt;Boolean&gt; = _isCommentSectionVisible<br><br>    private val _toastMessage = MutableSharedFlow&lt;ToastMessage&gt;()<br>    val toastMessage: SharedFlow&lt;ToastMessage&gt; = _toastMessage<br><br>    // Functions like loadDaynote(), toggleCommentSection(), etc...<br>}</pre><h3>Problems with This Approach:</h3><ol><li><strong>Scattered State</strong>: The UI has to observe multiple LiveData properties, leading to redundant updates and inconsistent states.</li><li><strong>Boilerplate</strong>: For every new state, we need a new LiveData property and corresponding logic.</li><li><strong>Hard to Test</strong>: Testing multiple LiveData properties individually increases complexity.</li></ol><h3>Step 2: Designing the Unified UiState</h3><p>First, we define a single UiState class to encapsulate all the state in the ViewModel:</p><pre>sealed class ViewDaynoteUiState {<br>    object Loading : ViewDaynoteUiState()<br>    data class Success(<br>        val daynote: Daynote,<br>        val userPreview: UserPreview,<br>        val isLiked: Boolean,<br>        val isCurrentUser: Boolean,<br>        val isCommentSectionVisible: Boolean = false,<br>        val comments: List&lt;Comment&gt; = emptyList(),<br>    ) : ViewDaynoteUiState()<br>    object Error : ViewDaynoteUiState()<br>    object Deleted : ViewDaynoteUiState()<br>}</pre><p>This structure:</p><ul><li>Consolidates all state into a single object.</li><li>Adds meaningful states like Loading, Error, and Deleted.</li><li>Simplifies state transitions during operations like deleting a daynote.</li></ul><h3>Step 3: Refactoring the ViewModel</h3><p>Next, we replace the scattered LiveData properties with a single StateFlow for the UI state:</p><pre>class ViewDaynoteViewModel : ViewModel() {<br>    private val _uiState = MutableStateFlow&lt;ViewDaynoteUiState&gt;(ViewDaynoteUiState.Loading)<br>    val uiState: StateFlow&lt;ViewDaynoteUiState&gt; = _uiState<br><br>    var commentText = MutableStateFlow(&quot;&quot;)<br><br>    fun loadDaynote(daynoteId: String) {<br>        viewModelScope.launch {<br>            _uiState.value = ViewDaynoteUiState.Loading<br>            val result = daynoteRepository.getDaynoteById(daynoteId).flatMap { daynote -&gt;<br>                userRepository.getUserPreviewById(daynote.userId).map { userPreview -&gt;<br>                    Triple(daynote, userPreview, daynote.userId == currentUserId)<br>                }<br>            }<br><br>            result.onSuccess { (daynote, userPreview, isCurrentUser) -&gt;<br>                val isLiked = likeRepository.isDaynoteLikedByUser(daynoteId, currentUserId!!)<br>                _uiState.value = ViewDaynoteUiState.Success(<br>                    daynote = daynote,<br>                    userPreview = userPreview,<br>                    isLiked = isLiked,<br>                    isCurrentUser = isCurrentUser,<br>                )<br>                loadComments(daynoteId)<br>            }.onFailure {<br>                _uiState.value = ViewDaynoteUiState.Error<br>            }<br>        }<br>    }<br><br>    fun toggleCommentSection() {<br>        val currentState = _uiState.value<br>        if (currentState is ViewDaynoteUiState.Success) {<br>            _uiState.value = currentState.copy(<br>                isCommentSectionVisible = !currentState.isCommentSectionVisible<br>            )<br>        }<br>    }<br><br>    fun deleteDaynote(daynoteId: String) {<br>        viewModelScope.launch {<br>            val result = daynoteRepository.deleteDaynote(daynoteId)<br>            result.onSuccess {<br>                _uiState.value = ViewDaynoteUiState.Deleted<br>            }.onFailure {<br>                _toastMessage.emit(ToastMessage.Error(&quot;Failed to delete daynote&quot;))<br>            }<br>        }<br>    }<br><br>    // Additional logic for comments, likes, etc.<br>}</pre><h3>Key Changes:</h3><ol><li><strong>StateFlow for Unified State</strong>: All UI state is derived from _uiState.</li><li><strong>Simpler State Management</strong>:</li></ol><ul><li>Operations like toggling the comment section update the state with copy().</li><li>The UI automatically updates because it observes uiState.</li></ul><h3>Step 4: Refactoring the Screen</h3><p>Finally, we update the ViewDaynoteScreen to consume the new unified uiState:</p><pre>@Composable<br>fun ViewDaynoteScreen(<br>    navigateBack: () -&gt; Unit,<br>    daynoteId: String,<br>    onTitleChange: (String) -&gt; Unit,<br>    viewModel: ViewDaynoteViewModel = hiltViewModel()<br>) {<br>    val uiState by viewModel.uiState.collectAsState()<br>    val commentText by viewModel.commentText.collectAsState()<br><br>    when (val state = uiState) {<br>        is ViewDaynoteUiState.Loading -&gt; {<br>            Box(<br>                modifier = Modifier.fillMaxSize(),<br>                contentAlignment = Alignment.Center<br>            ) {<br>                CircularProgressIndicator()<br>            }<br>        }<br><br>        is ViewDaynoteUiState.Success -&gt; {<br>            LazyColumn {<br>                item {<br>                    DaynoteCard(<br>                        note = state.daynote,<br>                        userInfo = state.userPreview,<br>                        isDaynoteLiked = state.isLiked,<br>                        isCurrentUser = state.isCurrentUser,<br>                        onCommentSectionVisible = { viewModel.toggleCommentSection() },<br>                        onLikeDaynote = viewModel::toggleDaynoteLike,<br>                        onDeleteDaynote = { /* Show delete dialog */ }<br>                    )<br>                }<br><br>                if (state.isCommentSectionVisible) {<br>                    item {<br>                        CommentEntrySection(<br>                            commentText = commentText,<br>                            onCommentTextChanged = { viewModel.commentText.value = it },<br>                            onSendComment = viewModel::sendComment<br>                        )<br>                    }<br>                }<br><br>                items(state.comments) { comment -&gt;<br>                    CommentCard(comment)<br>                }<br>            }<br>        }<br><br>        is ViewDaynoteUiState.Error -&gt; {<br>            Box(<br>                modifier = Modifier.fillMaxSize(),<br>                contentAlignment = Alignment.Center<br>            ) {<br>                Text(&quot;Failed to load daynote&quot;, color = Color.Red)<br>            }<br>        }<br><br>        is ViewDaynoteUiState.Deleted -&gt; {<br>            navigateBack()<br>        }<br>    }<br>}</pre><h3>Why the New Approach Works</h3><ol><li><strong>Cleaner ViewModel</strong>:</li></ol><ul><li>All logic is tied to uiState.</li><li>There’s less duplication and easier state transitions.</li></ul><p><strong>2. Simpler Screen</strong>:</p><ul><li>The screen renders the UI based on the uiState.</li><li>Each state (Loading, Success, Error) maps directly to a specific UI.</li></ul><p><strong>3. Easier Debugging</strong>:</p><ul><li>Observing a single StateFlow simplifies debugging and testing.</li></ul><h3>Conclusion</h3><p>Refactoring to a unified state design can seem daunting initially, but it greatly simplifies your code in the long run. By consolidating all UI-related data into a single UiState, you make your ViewModel more maintainable and your screens easier to read.</p><p>This approach also prepares your app for scalability, enabling you to handle more complex features or states with minimal effort.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=706a750b4bb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Fascinating Parallels Between Object-Oriented Programming and Nature]]></title>
            <link>https://muratgny06.medium.com/10-fascinating-parallels-between-object-oriented-programming-and-nature-f19503b6d23e?source=rss-db48bf9511f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f19503b6d23e</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[oop-concepts]]></category>
            <category><![CDATA[oop]]></category>
            <dc:creator><![CDATA[Murat Gunay]]></dc:creator>
            <pubDate>Sat, 07 Dec 2024 17:32:57 GMT</pubDate>
            <atom:updated>2024-12-07T17:32:57.530Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*vmgMr4du0k20JgTe1Zle_A@2x.jpeg" /></figure><p>Object-Oriented Programming (OOP) isn’t just a technical methodology — it mirrors the natural world in surprising ways. By exploring these parallels, we uncover deeper patterns of organization, adaptability, and efficiency shared by life and code. Here are ten distinctive and thought-provoking similarities, refined for clarity and depth.</p><ol><li><strong>Encapsulation: Nature’s Protective Barriers</strong></li></ol><p>Encapsulation in OOP mirrors the protective systems in nature. For instance, cells are enclosed by membranes that shield internal processes while allowing selective interaction with the outside world through pores or channels. In OOP, objects protect their internal data and expose functionality through controlled interfaces like deposit() or withdraw().</p><p>This principle fosters security and stability, ensuring that both natural and digital systems function efficiently without external interference.</p><p><strong>2. Inheritance: Passing Down the Blueprint of Life</strong></p><p>Inheritance in nature is a cornerstone of evolution. Genetic traits, like a bird’s ability to fly or a plant’s resistance to drought, are passed down from one generation to the next. In OOP, classes pass properties and methods to their subclasses. For example, a “Vehicle” class might pass attributes like “speed” or “fuel type” to its derived classes, such as “Car” or “Bicycle.”</p><p>This shared inheritance forms the basis for specialization and diversity, whether in ecosystems or programming.</p><p><strong>3. Modular Design: Independent Units in Ecosystems</strong></p><p>Ecosystems thrive as modular systems, with each organism playing a specialized role. Bees pollinate flowers, fungi decompose organic matter, and predators maintain population balance. Similarly, OOP systems are composed of independent modules — such as authentication, data storage, or payment processing — each handling a specific responsibility.</p><p>This modularity ensures resilience, adaptability, and scalability in both natural and digital domains.</p><p><strong>4. Abstraction: Hiding Complexity in Layers</strong></p><p>Nature and OOP both rely on abstraction to simplify complexity. Drivers interact with cars through steering wheels and pedals, without needing to understand the engine’s mechanics. Similarly, in programming, abstraction hides lower-level processes behind user-friendly interfaces, like a print() function that abstracts printer hardware operations.</p><p>Abstraction enhances usability and focus, letting both organisms and programmers concentrate on higher-level tasks.</p><p><strong>5. Polymorphism: Adapting Roles for Flexibility</strong></p><p>Polymorphism reflects the flexibility inherent in nature and OOP. In biology, water adapts to its environment by existing as ice, liquid, or vapor. In OOP, polymorphism allows a single interface to perform different functions depending on the object. For example, a draw() method might render a circle for a “Circle” object or a square for a “Rectangle” object.</p><p>This adaptability ensures survival in changing conditions, whether in life or software.</p><p><strong>6. Recursive Patterns: Fractals in Nature and Algorithms</strong></p><p>Recursion is a shared feature of nature and programming. In nature, recursive patterns are evident in fractals like snowflakes, tree branches, or river networks. In OOP, recursion is a powerful tool for solving problems by breaking them into smaller, self-similar subproblems, such as navigating a directory structure or computing factorials.</p><p>These patterns illustrate how simple rules can create stunning complexity.</p><p><strong>7. Dynamic Behavior: Adapting in Real Time</strong></p><p>Dynamic systems in nature and OOP adapt to new circumstances. Animals migrate to escape harsh weather, and plants grow toward sunlight. Similarly, OOP systems adapt during runtime by modifying their state or behavior. A weather app, for instance, updates its interface when new data arrives, much like a tree sheds leaves in winter.</p><p>This real-time adaptability fosters resilience in both domains.</p><p><strong>8. Hierarchical Organization: Nested Systems Everywhere</strong></p><p>Nature and OOP organize their components hierarchically. Cells form tissues, tissues form organs, and organs form organisms. In OOP, hierarchies exist between classes, objects, and modules. For instance, a “Plant” class might belong to a “Botany” module, which is part of a broader “Biology” library.</p><p>This hierarchical structure allows for complexity to be managed and scaled effectively.</p><p><strong>9. Cooperation Through Interfaces: Symbiotic Relationships</strong></p><p>Symbiosis in nature, such as bees pollinating flowers, mirrors the role of interfaces in OOP. Interfaces define how different objects interact while remaining independent. For instance, multiple classes can implement a “PaymentGateway” interface to process payments differently but seamlessly.</p><p>This cooperative design ensures smooth functionality and balance in both natural and technical ecosystems.</p><p><strong>10. Emergent Behavior: Complexity from Simple Interactions</strong></p><p>One of the most fascinating parallels is emergent behavior. In nature, ant colonies coordinate complex tasks despite individual ants following simple rules. Similarly, OOP systems often exhibit emergent behavior when multiple objects interact. For example, recommendation engines use algorithms and user data to deliver unexpectedly accurate suggestions.</p><p>This phenomenon demonstrates how simple interactions can lead to complex, intelligent systems.</p><p><strong>Conclusion</strong></p><p>These parallels between OOP and nature reveal shared principles of efficiency, adaptability, and organization. Encapsulation safeguards internal processes, modularity fosters independence, and hierarchical structures manage complexity. Together, these insights deepen our understanding of both programming and the natural world, showing that innovation often imitates life itself. By studying these connections, we can continue to draw inspiration from the intricate systems around us.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f19503b6d23e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Developers Can Maximize the Potential of AI in Software Development]]></title>
            <link>https://muratgny06.medium.com/how-developers-can-maximize-the-potential-of-ai-in-software-development-78ec3cd74998?source=rss-db48bf9511f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/78ec3cd74998</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[junior-developer]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Murat Gunay]]></dc:creator>
            <pubDate>Fri, 29 Nov 2024 14:54:07 GMT</pubDate>
            <atom:updated>2024-11-29T14:54:07.983Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>How Developers Can Maximize the Potential of AI in Software Development</strong></p><figure><img alt="AI comic produced by AI" src="https://cdn-images-1.medium.com/max/1024/1*bavilEk-UZBIkjwySS4J1Q.jpeg" /><figcaption>AI produced image :)</figcaption></figure><p>Artificial intelligence (AI) has revolutionized numerous industries, and software development is no exception. The ability of AI to assist developers, generate code, and provide solutions has undeniably transformed the way we build software, apps, and websites. However, there are some widespread misunderstandings about how AI should be used effectively in software development. Misusing AI can often lead to wasted time, buggy results, or even complete failure in achieving project goals.</p><p>This article focuses on these common issues, provides insights into how developers should approach AI, and offers strategies for leveraging it as a true assistant rather than an overestimated tool.</p><h3>Common Misconceptions About AI in Software Development</h3><ol><li><strong>Using AI to Generate Large Code Blocks Without Understanding Them</strong><br>One of the biggest mistakes developers make is treating AI as a tool to generate extensive code blocks and then attempting to decipher or debug those blocks later. For instance, some developers ask AI to write a fully functional payment gateway or an entire backend system, expecting the results to be perfect.</li></ol><p>However, this approach often leads to frustration because:</p><ul><li><strong>The code might include logical errors or bugs.</strong></li><li><strong>Deprecated libraries might be used.</strong> For example, an AI might include a library that has been replaced with newer ones or is no longer supported.</li><li><strong>Incomplete code snippets.</strong> Sometimes, AI-generated code refers to variables or functions that are undefined, leaving developers scrambling to figure out what is missing.</li></ul><p><strong>Example Case:</strong><br>A developer asks AI to create a login system with email verification. The AI produces a significant portion of the code, but the library it uses for email handling is outdated. On top of that, the AI forgets to define a variable for user authentication. The developer, who was expecting a “plug-and-play” solution, ends up spending hours debugging and researching replacements for outdated code. In this scenario, the developer could have saved time by breaking the problem into smaller, well-defined parts and seeking targeted help from the AI.</p><p><strong>2. Providing Insufficient Information to the AI</strong><br>AI is only as good as the input it receives. Many developers fail to provide the context or details necessary for the AI to generate an accurate solution. A vague prompt like “Create a search feature for my app” might lead to generic, incomplete results that don’t align with the project’s actual requirements.</p><p><strong>Example Case:</strong><br>Suppose a developer is building an e-commerce platform and asks AI to create a search function. Without specific details such as the platform’s backend (e.g., Node.js, Django, etc.), the structure of the database, or the type of search (full-text, filter-based, etc.), the AI can only provide generic code that requires heavy modifications. This lack of precision often results in wasted time and effort.</p><p><strong>3. Relying on AI to Solve Complex Problems Without a Foundation of Knowledge</strong><br>Some developers, especially beginners, rely too heavily on AI for solving complex problems, believing it can handle everything from logic to architecture. While AI can provide valuable assistance, it cannot fully replace the problem-solving skills and expertise of a developer.</p><p><strong>Example Case:</strong><br>A beginner programmer attempts to create a recommendation system for a movie app using AI-generated code. The code uses machine learning concepts, but the developer lacks an understanding of data preprocessing, training models, or evaluating accuracy. As a result, they struggle to adapt the code to their use case and eventually abandon the project.</p><p>This highlights an important point: <strong>AI is not a substitute for foundational knowledge.</strong> Developers need to understand the tools and concepts they are working with to effectively use AI-generated code.</p><h3>How to Use AI Effectively in Software Development</h3><p>To benefit from AI at the maximum level, developers need to approach it as an assistant, not as a magical solution. Below are some best practices for using AI effectively:</p><h4>1. Use AI for Smaller, Well-Defined Tasks</h4><p>Instead of asking AI to build an entire application or feature, break the task into smaller, manageable parts and provide clear, specific instructions. This makes it easier to integrate AI-generated solutions into your codebase and reduces the chances of errors.</p><p><strong>Example:</strong><br>If you’re building a to-do app and need a date-picker feature, you can ask the AI something like:<br><em>“Generate a JavaScript function using React to implement a date picker with the option to select a range of dates.”</em></p><p>By narrowing the focus, you’re more likely to get usable and error-free code.</p><h4>2. Provide Detailed Context</h4><p>AI thrives on clarity and detail. When asking for help, make sure to include:</p><ul><li>The programming language/framework you’re using.</li><li>The purpose of the code.</li><li>Relevant constraints or conditions.</li></ul><p><strong>Example:</strong><br>If you’re asking for help with a REST API, instead of saying:<br><em>“Generate a POST endpoint,”</em><br>provide more details like:<br><em>“Generate a POST endpoint in Express.js to add a new user to a MongoDB database. The user object should include name, email, and age, and it should validate the email format.”</em></p><p>This reduces ambiguity and improves the quality of the response.</p><h4>3. Treat AI as a Collaborative Assistant, Not a Lead Developer</h4><p>AI is excellent at handling repetitive tasks, generating boilerplate code, or providing suggestions for specific problems. However, as a developer, you should take the lead in designing and implementing the overall structure of your project.</p><p>Use AI for tasks like:</p><ul><li>Writing utility functions.</li><li>Generating test cases.</li><li>Refactoring code.</li><li>Drafting initial versions of documentation.</li></ul><p><strong>Example:</strong><br>If you’re creating a file upload feature, you can ask AI to draft a function for handling file uploads in your preferred framework. However, you should carefully review and test the code to ensure it aligns with your project’s requirements and security standards.</p><h4>4. Always Verify AI-Generated Code</h4><p>AI is not infallible. It can make mistakes, suggest outdated libraries, or overlook important details. Always review, test, and debug any AI-generated code before using it in your project.</p><p><strong>Example:</strong><br>A developer used AI to generate code for a chatbot feature. The AI recommended using a library that had been deprecated. By verifying the code and researching alternative libraries, the developer was able to replace the outdated code and avoid potential issues.</p><h4>5. Don’t Rely Solely on AI if You Lack Knowledge</h4><p>Developers must have a solid understanding of programming concepts and principles to effectively use AI. Without this foundation, it’s easy to misinterpret AI-generated code or fail to adapt it to your needs.</p><p><strong>Example:</strong><br>If you’re building a financial app but don’t understand encryption or secure data handling, relying on AI to implement security features is risky. Learn the basics of secure coding first, and then use AI to assist with specific tasks.</p><h3>Why Developers Need a Strong Foundation in Programming</h3><p>AI is a tool, not a replacement for skills. Developers who lack a strong foundation in programming are more likely to encounter the following problems:</p><ul><li><strong>Misusing AI-generated code:</strong> Without understanding how the code works, they might introduce vulnerabilities or inefficiencies into their projects.</li><li><strong>Wasting time on debugging:</strong> Fixing errors in AI-generated code can be more time-consuming than writing the code from scratch.</li><li><strong>Failing to adapt AI solutions:</strong> Developers need the knowledge to modify and improve AI-generated code to fit their specific requirements.</li></ul><p>On the other hand, developers with solid programming knowledge can use AI as a powerful assistant to accelerate their work and improve efficiency. They can spot errors quickly, adapt code with ease, and leverage AI for repetitive or time-consuming tasks.</p><h3>Final Thoughts: Developers Should Lead, AI Should Assist</h3><p>The key to maximizing the potential of AI in software development is balance. Developers should use AI to assist with specific tasks, generate ideas, or solve smaller problems — but they must remain in control of the process. Clear communication with AI, attention to detail, and a strong foundation in programming are essential for success.</p><p>Think of AI as a junior team member. You wouldn’t delegate critical decisions or complex tasks to a junior developer without guidance or review. Similarly, you should guide and verify AI’s output to ensure it meets your project’s requirements.</p><p>In the rapidly evolving world of software development, AI is a powerful ally — but only if used wisely. By treating AI as an assistant and combining it with strong programming skills, developers can unlock its full potential and build better, faster, and more reliable solutions.</p><p>Note: This article was prepared with the assistance of AI, under the guidance and direction of the writer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78ec3cd74998" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Starting a Tech Business: Key Steps, Lessons, and Real-Life Success Tips]]></title>
            <link>https://muratgny06.medium.com/starting-a-tech-business-key-steps-lessons-and-real-life-success-tips-6ec2d3ebd0e0?source=rss-db48bf9511f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ec2d3ebd0e0</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[ideas-to-execution]]></category>
            <category><![CDATA[creative-process]]></category>
            <dc:creator><![CDATA[Murat Gunay]]></dc:creator>
            <pubDate>Thu, 28 Nov 2024 23:54:25 GMT</pubDate>
            <atom:updated>2024-11-29T00:40:22.087Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eEZH3roqR4n6tDvmRn3YiQ.jpeg" /></figure><p>Every great startup begins with an idea, but turning that idea into reality is a challenge that stumps many entrepreneurs. After working on dozens of startup projects as a freelance developer, I’ve learned that success comes down to a few key steps. In this article, I’ll share the lessons I’ve learned to help others bring their ideas to life.</p><p>I have developed numerous projects that first come to my customers’ minds after they decide to take action to make these projects real. Whether a freelance developer working on a startup project or the project owner, you need to be ensure you are clear about every development step. And the most vital part is to understand these steps. If you skip any of them, you may face more problems for yourself and for the project’s success.</p><p>Below I will show you the steps under subtitles and try to explain them in detail. I hope, this helps people who has been working as freelancers for the whole project or are trying to establish their own startup company.</p><ol><li><strong>Deciding on the idea and its basic requirements</strong></li></ol><p>After deciding to bring an idea to life, you need to think about the idea in detail and the requirements for this new project. Before I accept a project like this, I ask several questions to the owner of the idea such as;</p><ul><li>What is your complete idea for the project?</li><li>What is your goal in creating this project?</li><li>Who will be your target group?</li><li>On which platform do you want to publish it?</li><li>What are your priorities for the project?</li><li>What will be the core task of your app?</li><li>What is your budget?</li><li>Is there any time limit to complete the project?</li><li>Is there any similar project in the market that is already working? If yes, what will make your project different?</li><li>How many people will be needed to work on this project?</li></ul><p>After discussing these questions, if I believe in the project, I agree to develop it. I think, answering these questions is the most critical part of the project. For example, time limits, budgets and the number of people are physical constraints of the project and if there is any inconsistency or incompability between them, the project is likely to fail. Or by answering the questions about the idea, you can see certain weak sides that could potentially affect the success of the project in the future.</p><p>As you can see, the first step is the most vital part of the project. If you want to have a successful project, you need to write these answers on a paper, review them repeatedly, compare them with each other to see if there is any inconsistency between them. If there is, think about the answers again, handle incompabilities then check them again until you have a powerful project idea. But there is one thing you need to be careful about; after handling the inconsistencies, your idea might be changed into another thing or maybe a weaker idea. So, this step is crucial. Do not hurry! You need enough time to think it through. If you don’t, you may face a possible failure in the future.</p><p><strong>2. Creating Basic Designs and Deciding on the Details</strong></p><p>After completing the first step, it is time to take action. I generally suggest creating basic UI designs for the project. Below, you will see an initial design for a social media app that I prepared for the customer and together we discussed this basic structure and talked about further details like, such as;</p><ul><li>Does the app need a chat feature between users?</li><li>Should the app have a “follow” feature?</li><li>Should the app have a “friendship” feature?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s21hH-XI0dyXEX5D07FpHg.jpeg" /><figcaption>First design for a mobile app</figcaption></figure><p>The approach I suggest for creating an app is fast-paced development. Not a “test first, code second” approach. Most customers want to see a working app quickly to stay motivated. But main reason I prefer this approach is quickly see a demo app to re-evaluate the app idea. Sometimes, after seeing a real product in our hands, ideas can change or expand their boundries. If you spend too much time on a test-first approach, and then the customer does not like what they see, the idea or some features might change, and in such cases, it leads to wasted time and budget. This is the second and often-overlooked part, I think.</p><p><strong>3. Building a demo, re-evalution of the project and deciding on details and boundries of the app</strong></p><p>The third step is creating a demo on a real device and talking about the project and the idea by asking thought-provoking questions, like below;</p><ul><li>Is the main idea still valid?</li><li>Is there any unnecessary feature in the project?</li><li>Does the project and idea seem strong?</li><li>Is there any change that needs to be done in details?</li><li>Is there any new feature that could be added to the project based on market research?</li><li>What are the business rules for every page or screen? For example, rules for becoming friends, follow rules, commenting rules, authorization rules, user profile privacy rules.</li><li>What design style will the project be developed in? Ex: Monolith, Modular, Microservices or another architecture. (My personal suggesttion is to start with the simpler one. It can be changed to a more complex one later if needed.)</li></ul><p>Both developers and the owner should talk about these topics and conduct a self-check and take notes about the rules and boundaries of the project.</p><p>Production of a demo with simple UI designs may take one week to four weeks depending on the project type. The aim is to see a simple example with non-real data.</p><p><strong>4. Building the Project and Weekly Meetings</strong></p><p>This step is the simplest because everything has already been clarified. You understand both the goals and the discussion points. Developing the project may take a long time but at every little step, meetings should be held between people who are involved in the project. If you are working alone to build the project yourself, you have to take a break after every development step and set aside time to reflect on the project.</p><p>In weekly or periodic meetings, you can talk about the features that have been developed and discuss deep specific details for UI, system design and logic. If you come up with new ideas for the project, you need to add them to the main place where you maintain the project’s core documentation. By adding new things to this document, by the end of development, you will have comprehensive documentation which includes the philosophy and aim of the project, system design, business rules, special rules for authentication and so on.</p><p>In addition, you will have a chance to revise detailed elements of the app during this development process. Later, you will realize that the initial plans and designs for the project weren’t perfect. It will continue to evolve toward perfection during this step.</p><p>I want to share a bad meeting experience I had while working on a project. In our weekly meetings, there were two owners, one junior UI designer, and me as the developer. The owners believed they knew everything about their project, but in reality, nothing was clear. When I started working on the project, the UI designs were already prepared. However, when I asked some critical questions, such as:</p><ul><li>Why do we need this graphic here?</li><li>Why do we have the same data on different screens?</li><li>Do we really need this section here?</li></ul><p>I asked these questions to ensure that I wouldn’t need to recreate or modify these parts later. Despite my efforts to clarify things, after two months of development, the owners decided to change the entire UI. I had to wait an additional month for the new designs. Once the new designs were ready, they didn’t allow me to provide feedback or even ask questions about them. One of the owners told me, “Our UI designer is responsible for everything,” meaning I shouldn’t ask questions or offer suggestions.</p><p>However, when I had a one-on-one discussion with the UI designer, I discovered that even he wasn’t sure why he had designed things in a particular way. His designs kept changing based on the questions I asked, which further delayed the process.</p><p>As a result, the project could not be completed. The main issues were:</p><ol><li><strong>Communication problems</strong></li><li><strong>Unprofessional management</strong></li><li><strong>Unwillingness to collaborate as a team</strong></li><li><strong>Poor planning, or no planning at all</strong></li><li><strong>Lack of core documentation</strong></li><li><strong>Absence of team spirit</strong></li></ol><p>This experience taught me the importance of open communication, proper planning, and teamwork in the success of a project.</p><p>Now I am adding a sample project that uses real-data that I have been developing and leading for a customer. It is like a simple twitter app at this stage. I won’t share the parts that include its uniqueness.</p><p>If the owner and the developers see a working project, they will feel satisfaction and motivation for the next steps.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fj0mF6-zLnKE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dj0mF6-zLnKE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fj0mF6-zLnKE%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6dee31881ad61e1e63243eb0a0669948/href">https://medium.com/media/6dee31881ad61e1e63243eb0a0669948/href</a></iframe><p><strong>5. Testing and Feedbacks</strong></p><p>After the development process is completed with the finalized user interface, now it is time for testing. Every team or developer must be ready for the testing phase because until this step, there was no testing process except tests done by developers to check out the app functionalities.</p><p>There could be different approaches to testing depending on the project type. If you have a project whose main focus is users, like a social media app, you need to focus on that area more thoroughly to identify potential issues. If your content has more importance, you need to handle possible problems in that area. This means you should balance between different parts of the app during testing. If you have time, you can aim to create a well-prepared testing environment.</p><p>For example, let’s talk about Exxen platform which is an online video streaming platform in Turkey. The owner who had unlimited budget decided to create this project and hired a company to do it. But the time was extremely limited. They needed to complete it by the launch date which was announced earlier. When the time came, the website went live, but there were numerous missing parts on the website. Even other developers made fun of the website on social media. But users seemed happy because they were able to access the content without major issues by subscribing to the website with a payment. Now Exxen platform is one of the biggest streaming platforms in Turkey. They reached their goal without major setbacks by simply handling the main part without failures.</p><p>I will share a second example from my previous work in which I was the only developer for the project and completed all the tasks to make it work. I suggested to the company that we need some sample users to try it. I had implemented a logging system and error detection system. So, these sample users downloaded the app and used it for about 15 minutes. We got feedback from them by asking their experiences in the app. And at the same time I monitored all the problems that they faced through my admin app screen. After getting feedback and log messages displayed on my screen, I fixed some bugs and we tested the app again using these sample users. Then, I finally published the app on the marketplace. And we did not have any major issues by checking everything manually step by step.</p><p>Now, we, developers have tools like “Github Actions” and similar platforms. Many tests can be largely automated. If the owner has a budget for implementing an advanced testing system, that would be a perfect way to achieve it, I think.</p><p><strong>6. Advertisement, Finding Sponsors</strong></p><p>This last step depends entirely on your approach. Budget, clever ideas for advertisement, selecting ad platforms all play a role in this phase. Or you can choose slower, organic method and let the app grow its reputation on its own. If your project is solid, I think it will succeed with a little help. So, the power of the idea and presentation are key factors here.</p><p>In one of my past works, there was no budget for advertisement so I suggested creating social media accounts and sharing some sample contents daily taken directly from the app. After 60 days, the app had almost 1000 users. After 4 months, it reached 10000+ downloads in Google Play Store.</p><p>If your project is powerful and unique, it can often market itself. If you want rapid growth in popularity, you will need some budget and clever advertising strategies. If your idea is not unique but has strong infrastructure, you may need a larger budget to be known.</p><p><strong>Final Words</strong></p><p>If you want to establish a start-up, I think there are no certain rules. The way you choose to succeed must be based on the idea. Strength, type, target audience, platform type are most vital parts of the idea. But at the same time, quality of the developers, problem-solving abilities of overall team, budget limit and time limit are some additional factors contributing to its success.</p><p>You need to manage multiple parameters at the same time. It’s like playing chess against the challenges of business life and you need to think about every move carefully before making it. There is much to say about it but I think this article may help at least a little bit to people considering starting start their own business in tech field.</p><p>This text <strong>is not</strong> produced by AI :))</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ec2d3ebd0e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hiding the Top of the Screen When Scrolling Down in a List]]></title>
            <link>https://muratgny06.medium.com/hiding-the-top-of-the-screen-when-scrolling-down-in-a-list-ce17c865479f?source=rss-db48bf9511f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce17c865479f</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Murat Gunay]]></dc:creator>
            <pubDate>Tue, 03 Sep 2024 14:48:37 GMT</pubDate>
            <atom:updated>2024-09-03T14:48:37.862Z</atom:updated>
            <content:encoded><![CDATA[<p>I first saw that feature on Twitter App, and I liked it. I’ve noticed that many apps don’t have this feature, which I think is a flaw in UI design for usability. You can see my example below, and then I will explain how you can achieve it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*7G3-AGNDBu55yQcwGJIxfw.gif" /></figure><p>First, define required variables to control the animation.</p><pre>    // State to keep track of the scroll position<br>    val scrollState = rememberLazyListState()<br><br>    // Determine the scroll offset in pixels<br>    val scrollOffset by remember {<br>        derivedStateOf { scrollState.firstVisibleItemScrollOffset }<br>    }<br><br>    val firstVisibleItemIndex by remember {<br>        derivedStateOf { scrollState.firstVisibleItemIndex }<br>    }<br><br>    // Set the maximum height for the header<br>    val maxHeight = 170.dp // Adjust this to your desired maximum height<br>    val minHeight = 0.dp // Minimum height (collapsed)<br><br>    // Calculate the height of the header dynamically based on scroll position<br>    val headerHeight = remember(firstVisibleItemIndex, scrollOffset) {<br>        when {<br>            firstVisibleItemIndex &gt; 1 -&gt; minHeight // After scrolling past the second item, header stays collapsed<br>            firstVisibleItemIndex == 1 -&gt; max(minHeight.value, maxHeight.value - scrollOffset.toFloat()).dp<br>            else -&gt; maxHeight // Header is fully expanded before the second item is visible<br>        }<br>    }<br><br>    // Determine the alpha for the header fade-out effect<br>    val headerAlpha = if (headerHeight &gt; minHeight) {<br>        min(1f, headerHeight.value / maxHeight.value)<br>    } else {<br>        0f<br>    }</pre><p>Then, for top side section;</p><pre>//This part included in the main UI part.<br>ProfileHeaderSection(<br>            height = headerHeight,<br>            alpha = headerAlpha<br>        )<br><br><br>//Section is define seperately and used in the main part like above<br>@Composable<br>fun ProfileHeaderSection(height: Dp, alpha: Float) {<br>    Column(<br>        modifier = Modifier<br>            .fillMaxWidth()<br>            .padding(16.dp)<br>            .height(height)<br>            .graphicsLayer(<br>                alpha = alpha<br>            )<br>    ) {<br>        //Content goes here.....<br><br><br>    }<br>}</pre><p>For the content part that includes list of items:</p><pre>//This part included in the main UI part<br>ContentSection(scrollState = scrollState)<br><br>//This is a separate section for the content part and used in mian UI like above<br>@Composable<br>fun ContentSection(scrollState: LazyListState) {<br><br>    LazyColumn(modifier = Modifier.background(ColorBackground),<br>        contentPadding = PaddingValues(10.dp),<br>        state = scrollState<br>    ) {<br>        //Content of list item goes here...<br>    }<br>}</pre><p>This is the implementation of that feature. Code talks itself. No need to explain it more.</p><p>Happy coding...</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce17c865479f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom SearchBar with Jetpack Compose]]></title>
            <link>https://muratgny06.medium.com/custom-searchbar-with-jetpack-compose-fb8ae4d12ca8?source=rss-db48bf9511f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb8ae4d12ca8</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[mobile]]></category>
            <dc:creator><![CDATA[Murat Gunay]]></dc:creator>
            <pubDate>Thu, 23 May 2024 13:59:12 GMT</pubDate>
            <atom:updated>2024-05-23T13:59:12.936Z</atom:updated>
            <content:encoded><![CDATA[<p>You know that Jetpack Compose libraries are updated quite often, and I could not use their SearchBar composable for our app effectively due to some limitations. Therefore, I decided to create my own search bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*2bEUy6TM9gk6iMKzuQtvfw.png" /></figure><h3>1. Code</h3><p>I have used a generic T variable to make this implementation applicable for general use with any item type. As you can see, we do not have any specific data class in this composable. When you implement it in your screens, you need to specify the item list, how it will be displayed under the search bar after a search, the filter type, and, if desired, the height of the search bar (the default value is 30.dp).</p><p>This search bar also includes a filter icon next to the search box. You can open a filter screen if you have a UI for it. To do this, add an onFilterClick parameter to this function and pass it to the filter icon&#39;s onClick argument. In this article, I didn&#39;t implement this feature to keep things simple. If you don&#39;t need it, you can remove that part from the code below.</p><pre>@Composable<br>fun &lt;T&gt; CustomSearchView(items: List&lt;T&gt;,<br>                         itemContent: @Composable (T) -&gt; Unit,<br>                         filter: (T, String) -&gt; Boolean,<br>                         searchBarHeight: Dp = 30.dp) {<br><br>    var query by remember { mutableStateOf(TextFieldValue(&quot;&quot;)) }<br>    val keyboardController = LocalSoftwareKeyboardController.current<br>    var isSearchActive by remember { mutableStateOf(false) }<br><br>    Column(<br>        modifier = Modifier<br>            .fillMaxWidth()<br>            .padding(top = 5.dp, start = 5.dp, end = 5.dp, bottom = 0.dp)<br>    ) {<br>        Row(modifier = Modifier<br>            .fillMaxWidth()<br>            .height(searchBarHeight),<br>            verticalAlignment = Alignment.CenterVertically){<br>            Row(<br>                modifier = Modifier<br>                    .weight(1f)<br>                    .background(ColorTextFieldContainerDefault, shape = MaterialTheme.shapes.large)<br>                    .padding(horizontal = 8.dp)<br>            ) {<br>                BasicTextField(<br>                    value = query,<br>                    onValueChange = { newValue -&gt; query = newValue },<br>                    singleLine = true,<br>                    textStyle = LocalTextStyle.current.copy(fontSize = 18.sp, color = ColorTextPrimary),<br>                    modifier = Modifier<br>                        .weight(1f)<br>                        .padding(horizontal = 8.dp, vertical = 3.dp),<br>                    keyboardOptions = KeyboardOptions.Default.copy(<br>                        imeAction = ImeAction.Search<br>                    ),<br>                    keyboardActions = KeyboardActions(onSearch = {<br>                        keyboardController?.hide()<br>                        // Handle search action<br>                    }),<br>                    decorationBox = { innerTextField -&gt;<br>                        if (query.text.isEmpty()) {<br>                            Row(verticalAlignment = Alignment.CenterVertically){<br>                                Icon(<br>                                    imageVector = Icons.Default.Search,<br>                                    contentDescription = &quot;Search&quot;,<br>                                    tint = ColorTextSecondary<br>                                )<br>                                Text(&quot;Search...&quot;, color = Color.Gray, fontSize = 18.sp)<br>                            }<br>                            isSearchActive = false<br>                        }<br><br>                        isSearchActive = true<br>                        innerTextField()<br>                    }<br>                )<br><br>            }<br>            IconButton(onClick = { /* Handle filter action */ }) {<br>                Icon(<br>                    painter = painterResource(id = R.drawable.ic_filter),<br>                    contentDescription = &quot;Filter&quot;,<br>                    Modifier.size(searchBarHeight),<br>                    tint = ColorTextSecondary<br>                )<br>            }<br>        }<br><br><br>        Spacer(modifier = Modifier.height(8.dp))<br><br>        if (isSearchActive &amp;&amp; query.text.isNotEmpty()) {<br>            LazyColumn() {<br>                items(items.filter { filter(it, query.text) }) { item -&gt;<br>                    itemContent(item)<br>                }<br>            }<br>        }<br><br>    }<br>}</pre><h3>2. Implementation</h3><p>Below, you see the implementation of the CustomSearchBar. Inside it, there’s another composable named SearchListViewForPlant. This composable is a UI design for my specific data class type. You can set it up according to your needs. Alternatively, you can directly put a Text composable here instead of this composable function.</p><pre>CustomSearchView(<br>    mockListOfPlants, //list of items<br>    itemContent = { plant -&gt;  //UI design for list view<br>        SearchListViewForPlant(plant = plant)<br>    <br>    },<br>    filter = { plant, query -&gt; //filter query algorithm<br>      plant.plantId.contains(query, ignoreCase = true)<br>    }<br>)</pre><p>This below fuction “SearchListViewForPlant ”is my specific composable to show list items.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*tyEaETTuC6meanrLMGtRsw.png" /></figure><pre>@Composable<br>fun SearchListViewForPlant(plant: Plant){<br><br>    Card(<br>        modifier = Modifier<br>            .padding(5.dp)<br>            .fillMaxWidth()<br>            .height(60.dp),<br>        shape = RoundedCornerShape(size = 10.dp),<br>        colors = CardDefaults.cardColors(<br>            containerColor = ColorTextFieldContainerDefault,<br>        ),<br>        onClick = {}<br>    ) {<br>        Column(modifier = Modifier.fillMaxSize(),<br>            verticalArrangement = Arrangement.Center){<br>            Row(Modifier.height(25.dp)<br>                .fillMaxWidth()<br>                .padding(horizontal = 15.dp, vertical = 4.dp),<br>                horizontalArrangement = Arrangement.SpaceBetween){<br>                Text(<br>                    text = plant.city,<br>                    color = ColorTextPrimary<br><br>                )<br><br>                Text(<br>                    text = plant.plantId,<br>                    color = ColorTextPrimary<br>                )<br>            }<br><br>            Row(Modifier.height(25.dp)<br>                .fillMaxWidth()<br>                .padding(horizontal = 15.dp, vertical = 4.dp),<br>                horizontalArrangement = Arrangement.SpaceBetween){<br>                Text(<br>                    text = plant.type.toString(),<br>                    color = ColorTextPrimary<br>                )<br><br>                Text(<br>                    text = plant.currentStatus.toString(),<br>                    color = if(plant.currentStatus == PlantStatus.ONLINE) ColorOnline<br>                    else ColorOffline<br>                )<br>            }<br><br>        }<br>    }<br><br>}</pre><h3>Summary</h3><p>I wanted to share this custom search bar example to show that developers don’t need to rely solely on ready-to-use composables from the Jetpack team. With some basic knowledge of UI design using Jetpack Compose, anyone can quickly and effectively create their own custom composables.</p><p>Happy coding! :))</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb8ae4d12ca8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create Custom Graphics with Jetpack Compose and Kotlin on Android]]></title>
            <link>https://muratgny06.medium.com/how-to-create-custom-graphics-with-jetpack-compose-and-kotlin-on-android-710fa84ebca8?source=rss-db48bf9511f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/710fa84ebca8</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Murat Gunay]]></dc:creator>
            <pubDate>Thu, 09 May 2024 01:20:32 GMT</pubDate>
            <atom:updated>2024-05-09T01:31:16.438Z</atom:updated>
            <content:encoded><![CDATA[<p>While developing a mobile application with Kotlin + Jetpack Compose, I have needed to draw some special drawings. At first, I looked at the documentations but it was too limited to understand and create complex drawings. After some research and with the help of AI, I have created my special drawings using Compose.</p><p>I wanted to share them here because there are not many examples of it. I mean; how to use canvas and some drawing functions. So, lets see some examples from my drawings.</p><ol><li><strong>Draw Circle and put Icon and Text in it if needed</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*cLjCuNEyfM35nmpUPpi9DA.png" /></figure><pre>@Composable<br>fun DrawCircleGraphWithIcon(value: Int,<br>                            color: Color,<br>                            remainingPartColor: Color = ColorTextFieldContainerDefault,<br>                            iconDrawable: Int? = null,<br>                            text : String? = null,<br>                            contentColor : Color = ColorTextPrimary,<br>                            backgroundColor : Color = ColorBackground) {<br><br>    var radius by remember { mutableFloatStateOf(0f) }<br>    var canvasWidth by remember { mutableFloatStateOf(0f) }<br><br>    Box(modifier = Modifier<br>        .fillMaxSize()<br>        .background(backgroundColor)) {<br>        Canvas(modifier = Modifier.fillMaxSize()) {<br>            canvasWidth = size.width<br>            val canvasHeight = size.height<br><br>            val centerX = canvasWidth / 2f<br>            val centerY = canvasHeight / 2f<br>            radius = canvasWidth / 2.3f //arrange circle size<br><br><br><br>            val sweepAngle = (value / 100f) * 360f<br><br>            // Draw the incomplete part of the circle<br>            drawArc(<br>                color = remainingPartColor, <br>                startAngle = sweepAngle,<br>                sweepAngle = 360f - sweepAngle,<br>                useCenter = false,<br>                topLeft = Offset(centerX - radius, centerY - radius),<br>                size = Size(radius * 2, radius * 2),<br>                style = Stroke(width = radius/9f)//arrange stroke size according to radius<br>            )<br><br>            // Draw the completed part of the circle<br>            drawArc(<br>                color = color,<br>                startAngle = 0f,<br>                sweepAngle = sweepAngle,<br>                useCenter = false,<br>                topLeft = Offset(centerX - radius, centerY - radius),<br>                size = Size(radius * 2, radius * 2),<br>                style = Stroke(width = radius/6f)//arrange stroke size according to radius<br>            )<br>        }<br><br>        Column(modifier = Modifier.height(canvasWidth.dp).width(canvasWidth.dp),<br>            horizontalAlignment = Alignment.CenterHorizontally,<br>            verticalArrangement = Arrangement.Center){<br>            if(iconDrawable != null){<br>                Icon(<br>                    painter = painterResource(id = iconDrawable),<br>                    contentDescription = null,<br>                    modifier = Modifier<br>                        .size((radius / 4).dp),//arrange stroke size according to radius<br>                    tint = color<br><br>                )<br>            }<br><br><br>            if(text != null){<br>                if (contentColor != null) {<br>                    Text(text, fontSize = (radius / 16).sp,<br>                        color = contentColor,<br>                        fontWeight = FontWeight.Bold,<br>                        modifier = Modifier.padding(top = (radius / 24).dp))//arrange stroke size according to radius<br>                }<br>            }<br><br>        }<br><br>    }<br>}</pre><p>This is my special drawing function. I coded it for general usage across all the screens that I will use it. It takes parent composable’s width to draw circle. So ensure parent’s size and try to size parent as square if possible.</p><p>Additionally, I may need to include an icon and text in some screens, which can be easily done while using it. The same scenario applies to text. If you want you can design it according to your needs. I plan to define parameters for the circle lines.</p><p><strong>2. Draw line with an angle and animate a dot on it</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*q_q84YlBzqQhBpmNjhD5Zw.png" /></figure><pre>import android.graphics.Path<br>import androidx.compose.animation.core.Animatable<br>import androidx.compose.animation.core.AnimationSpec<br>import androidx.compose.animation.core.InfiniteRepeatableSpec<br>import androidx.compose.animation.core.LinearEasing<br>import androidx.compose.animation.core.RepeatMode<br>import androidx.compose.animation.core.infiniteRepeatable<br>import androidx.compose.animation.core.tween<br>import androidx.compose.foundation.Canvas<br>import androidx.compose.foundation.layout.Box<br>import androidx.compose.foundation.layout.padding<br>import androidx.compose.foundation.layout.size<br>import androidx.compose.runtime.Composable<br>import androidx.compose.runtime.LaunchedEffect<br>import androidx.compose.runtime.remember<br>import androidx.compose.ui.Alignment<br>import androidx.compose.ui.Modifier<br>import androidx.compose.ui.geometry.Offset<br>import androidx.compose.ui.graphics.Brush<br>import androidx.compose.ui.graphics.Color<br>import androidx.compose.ui.graphics.SolidColor<br>import androidx.compose.ui.graphics.StrokeCap<br>import androidx.compose.ui.graphics.drawscope.Stroke<br>import android.graphics.PathMeasure<br>import android.graphics.RectF<br>import androidx.compose.foundation.layout.Column<br>import androidx.compose.material3.Icon<br>import androidx.compose.ui.graphics.asComposePath<br>import androidx.compose.ui.graphics.painter.Painter<br>import androidx.compose.ui.tooling.preview.Preview<br>import androidx.compose.ui.unit.Dp<br>import androidx.compose.ui.unit.dp<br><br>@Composable<br>fun AnimatedEnergyFlowLine(cornerRadius: Dp, closenessToTheCircle: Dp) {<br>    val strokeWidth = 8f<br>    val gradientColors = listOf(Color.Blue, Color.Green)<br>    val animatableOffset = remember { Animatable(0f) }<br>    val animationSpec: InfiniteRepeatableSpec&lt;Float&gt; = infiniteRepeatable(<br>        animation = tween(2000, easing = LinearEasing),<br>        repeatMode = RepeatMode.Restart<br>    )<br><br>    LaunchedEffect(key1 = true) {<br>        animatableOffset.animateTo(<br>            targetValue = 1f,<br>            animationSpec = animationSpec as AnimationSpec&lt;Float&gt;<br>        )<br>    }<br><br>    Canvas(modifier = Modifier.size(200.dp)) {<br>        val width = size.width<br>        val height = size.height<br><br>        // Create the path using the native Android Path class<br>        //Todo - This path will be adjusted as rounded corner arch. Then it will be universal to change angles and directions of the path line.<br>        val path = Path().apply {<br>            moveTo(width * 0.5f, -(closenessToTheCircle).toPx()) // Start at the top center<br>            // Draw a line to the center of the canvas<br>            lineTo(width * 0.5f, height * 0.5f - cornerRadius.toPx())<br>            // Curve around the corner<br>            quadTo(width * 0.5f, height * 0.5f, width * 0.5f + cornerRadius.toPx(), height * 0.5f)<br>            // Continue the line to the right from the center<br>            lineTo(width + closenessToTheCircle.toPx(), height * 0.5f)<br>        }<br><br>        val pathMeasure = PathMeasure()<br>        pathMeasure.setPath(path, false)<br><br>        val pos = FloatArray(2)<br>        val tan = FloatArray(2)<br>        val distance = animatableOffset.value * pathMeasure.length<br>        pathMeasure.getPosTan(distance, pos, tan)<br><br>        val dotRadius = strokeWidth + 5f / 2<br>        val dotCenter = Offset(pos[0], pos[1])<br><br>        // Gradient<br>        val gradient = Brush.linearGradient(<br>            colors = gradientColors,<br>            start = Offset(width * 0.5f, 0f),<br>            end = Offset(width, height * 0.5f)<br>        )<br><br>        // Draw the path with gradient  (using android.graphics.path library)<br>        drawPath(<br>            path = path.asComposePath(),<br>            brush = gradient,<br>            style = Stroke(width = strokeWidth, cap = StrokeCap.Round)<br>        )<br><br>        // Draw the animated dot on the path<br>        drawCircle(<br>            brush = SolidColor(Color.White),<br>            radius = dotRadius,<br>            center = dotCenter<br>        )<br>    }<br>}</pre><p>This drawing is an unfinished work, but it serves as a good example of how to draw shapes and create animations. The white dot moves along the line and then starts again from the beginning. I will refactor it for universal usage by allowing parameters for angles, starting and ending positions, as well as gradient colors.</p><p><strong>3. Drawing colored lines with rounded corners</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*7mxmkxYqh0SvT-Mp2qYrxA.png" /></figure><pre>@Composable<br>fun DrawColoredLine(<br>    color: Color,<br>    strokeWidth: Dp,<br>    lengthFraction: Float // Value between 0 and 1, representing the fraction of the parent&#39;s width<br>) {<br>    val strokePx = with(LocalDensity.current) { strokeWidth.toPx() }<br><br>    Canvas(modifier = Modifier.fillMaxWidth()) {<br>        val parentWidth = size.width<br>        val lineLength = parentWidth * lengthFraction<br>        val start = Offset(0f, size.height / 2)<br>        val end = Offset(start.x + lineLength, size.height / 2)<br><br>        drawLine(<br>            color = color,<br>            start = start,<br>            end = end,<br>            strokeWidth = strokePx,<br>            cap = StrokeCap.Round<br>        )<br>    }<br>}</pre><p>It draws line with the specified strokeWidth and you can give its length by giving value between 0 and 1. I am starting its position from the parent composable’s left side. But you arrange it by changing “0f” in the start variable. It may not be perfect but it works excellent for our app.</p><p><strong>Result</strong></p><p>I got help from AI when I stucked at some points. I know that AI is not updated with the compose libraries that is changing continuously but if you give it the updated library’s required code, it helps you and give you different ways to do it. Happy coding to all silent coders :))</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=710fa84ebca8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Unit Tests]]></title>
            <link>https://muratgny06.medium.com/understanding-unit-tests-f7768c91010d?source=rss-db48bf9511f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7768c91010d</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[test-driven-development]]></category>
            <category><![CDATA[unit-test-tools]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[Murat Gunay]]></dc:creator>
            <pubDate>Wed, 14 Jun 2023 09:03:35 GMT</pubDate>
            <atom:updated>2023-06-19T10:18:13.156Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi everyone,</p><p>In this article, I will write about my understanding of unit testing. There are tons of documents on this topic, but I want to share my knowledge to improve myself better, and maybe this article will help someone who has difficulty understanding unit testing, just like I did. All of the statements will be based on my experiences and opinions, so please don’t judge me if you find any mistakes. Feel free to comment on the article to correct me.</p><p><strong>What is Unit Testing and Whydo you need it?</strong></p><p>Unit testing is a testing method performed by the developer who writes the program code. Developers test their own code with unit tests. It is not necessary to test every line of code in your program, but if there is a code block that may produce errors, it is better to write a test for it.</p><p>By writing unit tests, yes, you spend more time during the development process than usual. Why waste more time, right? It may seem that way to almost every new programmer. But it’s not true. You will realize that it saves more time when you continue to produce and develop the product. Which code is perfect in the first time? None. So, if you write unit tests, you can identify and correct errors produced by your code. You can easily refactor your code, and the tests work behind the scenes, allowing you to quickly see if your refactored code is correct or not.</p><p>Moreover, if you work in a team, your teammates can trust your code if you write unit tests. Think about a scenario where you write thousands of lines of code without unit tests, and your team can’t determine whether your code is working correctly or not. Sometimes, a minor error can result in the loss of thousands of working hours. So, if you want to be a good developer, use unit tests.</p><p><strong>How Does a Unit Test Work?</strong></p><p>I will explain this using examples from the .NET platform. There are several elements you need to know. Take a look at the list below:</p><ol><li>Create a separate unit test project alongside the main project in the same solution.</li><li>Add packages for unit testing (xUnit or NUnit) to this new project</li><li>Create a new class and name it with the class that will be tested, adding “Tests” to the end. Like that “ClassNameTests”</li><li>Inside this class, create a public method and name it in the format “ClassName_MethodName_SupposedResult.” Here, “MethodName” is the name of the method that will be tested, and “ClassName” is the class that contains this method.</li><li>Follow the AAA Rule: Arrange — Act — Assert. Write these parts inside your test method. This is the main part of unit testing and will be explained further.</li><li>Run the test.</li></ol><p><strong>What is the AAA Rule?</strong></p><p>This part actually contains the main unit test code. With unit tests, you do not test your code with real values. Instead, you provide different data for your test and test your code with this data. Your code does not function in reality. Unit test codes are separate from your actual code but use your actual code with the data provided in the test and return a result. Then, you compare the produced result with the expected result that you define within the test. This is essentially what unit testing is all about, but we can break it down into the AAA’s.</p><p><strong>Arrange:</strong> This part involves initializing and defining your variables, as well as any necessary tasks like creating temporary variables or initializing your expected result before calling your actual method.</p><p><strong>Act:</strong> This part is where you call your method from the main code and retrieve a result from it.</p><p><strong>Assert: </strong>This part involves comparing the produced result with your expected value. It determines whether the test is successful or not. If your expected result and the produced result are equal, the test passes.</p><p>If you understand the AAA rule, you grasp the basics of unit testing. <strong>It’s important to note that your test methods should focus on testing only one job. </strong>So, if you have a method that spans 300 lines, how do you effectively test it? You can’t. Unit tests encourage you to write simple and small pieces of code for your methods. You need to break down your large code blocks into smaller pieces to test them effectively. By doing so, you will also adhere to the SOLID principles. Now, we can move on harder part.</p><p><strong>What is Mocking or Faking?</strong></p><p>There is a process commonly referred to as ‘mocking’ or ‘faking,’ which serves the same purpose. It involves creating fake services or objects to be used in dependency injection or to avoid using the real ones.</p><p>In the .NET platform, there are different packages available for this specific task. The most common ones are Moq, NSubstitute, and FakeItEasy. They all serve the same purpose but utilize different techniques. You can choose any of them to mock everything you need. I will provide a link at the end of the article that explains the differences between them. I won’t provide code examples, as my aim is to help you understand the theory of unit testing.</p><p>For instance, let’s consider testing a database for CRUD operations. How would you test it? Would you connect to the real database? Absolutely not. Instead, you would mock it by creating a fake version. Then, you would use this fake service to perform the tests. This is just one example that illustrates the theory of mocking. It is essential for testing complex and diverse code blocks.</p><p><strong>Lastly</strong></p><p>I believe this provides a sufficient understanding of the logic behind unit testing. However, you should explore additional resources to utilize it effectively. I recommend the following resources to enhance your understanding.</p><ul><li><a href="https://blog.elmah.io/moq-vs-nsubstitute-vs-fakeiteasy-which-one-to-choose/">Differences between mocking packages</a></li><li>Look at youtube videos of <a href="https://www.youtube.com/@IAmTimCorey">Tim Corey</a> and <a href="https://www.youtube.com/@TeddySmithDev">Teddy Smith</a> to see real world examples of unit testing. They have explained unit testing great.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7768c91010d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formatting Text in Code Behind as Link, Bold and Italic Types]]></title>
            <link>https://muratgny06.medium.com/formatting-text-in-code-behind-as-link-bold-and-italic-types-9ec42c7284ae?source=rss-db48bf9511f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ec42c7284ae</guid>
            <category><![CDATA[xamarin]]></category>
            <category><![CDATA[xamarin-app-development]]></category>
            <category><![CDATA[xamarin-android]]></category>
            <category><![CDATA[xamarin-forms]]></category>
            <dc:creator><![CDATA[Murat Gunay]]></dc:creator>
            <pubDate>Wed, 24 Feb 2021 07:40:39 GMT</pubDate>
            <atom:updated>2024-11-21T09:43:46.747Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*6QgA3L9uG7J-vM1BGZgL9A.gif" /></figure><p>I needed a feature for one of my Xamarin Forms Projects. I searched online but can’t find any proper source to do what I want. Then code it myself. It can change some parts of text to links, bold or italic. I am using “FormattedString” type to make it. Change it for your special cases. The code is below. Have a nice coding…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/79585a5c935558d109021f821bd70429/href">https://medium.com/media/79585a5c935558d109021f821bd70429/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ec42c7284ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>