<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amr Hassan</title>
    <description>The latest articles on DEV Community by Amr Hassan (@amrh434).</description>
    <link>https://dev.to/amrh434</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F344284%2F3cc1ead5-6f72-4c71-b453-e8e953160282.jpg</url>
      <title>DEV Community: Amr Hassan</title>
      <link>https://dev.to/amrh434</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amrh434"/>
    <language>en</language>
    <item>
      <title>System design template</title>
      <dc:creator>Amr Hassan</dc:creator>
      <pubDate>Mon, 19 Dec 2022 09:12:56 +0000</pubDate>
      <link>https://dev.to/amrh434/system-design-template-754</link>
      <guid>https://dev.to/amrh434/system-design-template-754</guid>
      <description>&lt;p&gt;Most of the time I forget things in my system design interview or waste some time listing things, so I created the below template to help me with that and fasten the process a bit, feel free to use it and please let me know if you have some suggestions&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>MongoDB vs DynamoDB for your (side) project</title>
      <dc:creator>Amr Hassan</dc:creator>
      <pubDate>Sun, 04 Dec 2022 06:45:25 +0000</pubDate>
      <link>https://dev.to/amrh434/mongodb-vs-dynamodb-for-your-side-project-2n90</link>
      <guid>https://dev.to/amrh434/mongodb-vs-dynamodb-for-your-side-project-2n90</guid>
      <description>&lt;p&gt;So here I'm wanting to create an MVP for a side project of mine and look for the cheapest DB aka cheapest data provider to use and let my baby see the daylight with the possibility of scaling and paying less money of course, but before boring you with the comparison I need to tell you more about my use case.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data access layer (Functional)
&lt;/h2&gt;

&lt;p&gt;I need to list my data accessing pattern first which were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Insert schemaless data (obviously)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update the last seen of a record&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Query the last 5 elements&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the future queries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How many updated records per week, month, year&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Going to ignore the non-functional, come on it's a side project don't judge me&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Data ETA
&lt;/h2&gt;

&lt;p&gt;Assuming that most of the data types going to be text/string with a maximum size of 100KB per record.&lt;/p&gt;

&lt;p&gt;How many records going to store per week or month?&lt;/p&gt;

&lt;p&gt;10 in the day, 70 in the week, 300 records per month per user&lt;/p&gt;

&lt;p&gt;Assuming that we want to support 100 users as a start&lt;/p&gt;

&lt;p&gt;100 users * 300 records =&amp;gt; 30K per month with the size of 30k * 100KB =&amp;gt; 3GB per month&lt;/p&gt;

&lt;h2&gt;
  
  
  DynamoDB vs MongoDB
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;DynamoDB&lt;/th&gt;
&lt;th&gt;MongoDB&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;storage free tier&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Free 25 GB of storage&lt;/strong&gt; &lt;a href="https://aws.amazon.com/dynamodb/pricing/?loc=ft#Free_tier"&gt;AWS Free Tier&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;512MB to 5GB of storage Shared RAM Upgrade to dedicated clusters for full functionality No credit card required to start&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vendor lock-in&lt;/td&gt;
&lt;td&gt;amazon specific svc&lt;/td&gt;
&lt;td&gt;could use it on your side or Atlas's side&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;monitoring&lt;/td&gt;
&lt;td&gt;provisioning, monitoring, and keeping servers running (not to mention making backups).&lt;/td&gt;
&lt;td&gt;none unless you are using Atlas and would have limited feat compared to a dynamo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;security&lt;/td&gt;
&lt;td&gt;better&lt;/td&gt;
&lt;td&gt;meh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;record size&lt;/td&gt;
&lt;td&gt;400kb&lt;/td&gt;
&lt;td&gt;16 MB.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;query&lt;/td&gt;
&lt;td&gt;basic key-value lookup without the elastic map reduce&lt;/td&gt;
&lt;td&gt;better querying framework&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;data types&lt;/td&gt;
&lt;td&gt;number, string, and binary&lt;/td&gt;
&lt;td&gt;int, long, date, timestamp, geospatial, floating-point, and decimal128&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;consistency&lt;/td&gt;
&lt;td&gt;eventual data consistency No data validation - must be handled in application ACID transactions apply to table data only, not to indexes or backups Maximum of 25 writes per transaction&lt;/td&gt;
&lt;td&gt;strong data consistency Native schema governance and data validation ACID transactions apply to documents, indexes, and backups 1,000 operations per transaction (executing within 60 seconds by default)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;connections&lt;/td&gt;
&lt;td&gt;HTTPS - kinda unlimited&lt;/td&gt;
&lt;td&gt;TCP - M0/M2 cluster tier is 500 per node&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;indexing&lt;/td&gt;
&lt;td&gt;Limited / Complex to manage Indexes are sized, billed &amp;amp; provisioned separately from data&lt;/td&gt;
&lt;td&gt;Robust / Easy to develop against No extra cost to index your data&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For my use case dynamo fail on the querying side which is important for me compared to the storage and scale for now at least.&lt;/p&gt;

&lt;p&gt;Someday will have a use case to abuse dynamodb with but for now, my rational mind says no, for now, how about you would you do the same?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Did you know how discord/zoom works?</title>
      <dc:creator>Amr Hassan</dc:creator>
      <pubDate>Mon, 03 Oct 2022 19:41:33 +0000</pubDate>
      <link>https://dev.to/amrh434/did-you-know-how-discordzoom-works-5g4o</link>
      <guid>https://dev.to/amrh434/did-you-know-how-discordzoom-works-5g4o</guid>
      <description>&lt;p&gt;The secret ingredient is WebRTC.&lt;/p&gt;

&lt;p&gt;Here I think that the communication protocols I need to pick when developing a new solution are GRPC, REST, Websockets, and GraphQL.&lt;/p&gt;

&lt;p&gt;Thanks for reading Amrs Newsletter! Subscribe for free to receive new posts and support my work.&lt;/p&gt;

&lt;p&gt;Since we are talking about real-time communication by default we will drop others beside WebSockets.&lt;/p&gt;

&lt;p&gt;thats when I saw WebRTC when reading this discord article.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is WebRTC?
&lt;/h2&gt;

&lt;p&gt;WebRTC is a fully peer-to-peer technology for the real-time exchange of audio, video, and data, with one central caveat. A form of discovery and media format negotiation must take place.&lt;/p&gt;

&lt;p&gt;in order for two devices on different networks to locate one another. This process is called signaling and involves both devices connecting to a third, mutually agreed-upon server. Through this third server, the two devices can locate one another, and exchange negotiation messages.&lt;/p&gt;

&lt;h2&gt;
  
  
  So here is my short reflection:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Good side
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fast as long as your use case doesnt require all packets delivery in order&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Uses UDP which explains why its faster than WebSocket which uses TCP.&lt;/p&gt;

&lt;p&gt;peer-to-peer technology and once the connection is up and running, you do not need to pass the communication via a server (unless using TURN).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Secure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With WebSockets, the data has to go via a central webserver which typically sees all the traffic and can access it.&lt;/p&gt;

&lt;p&gt;With WebRTC the data is end-to-end encrypted and does not pass through a server (except sometimes TURN servers are needed, but they have no access to the body of the messages they forward).&lt;/p&gt;

&lt;p&gt;I was curious to see its compatibility with all browsers; it seems solid &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fay6j37pjc574nuh1200c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fay6j37pjc574nuh1200c.png" alt="Screenshot from 2022-10-03 20-43-01.png" width="800" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://caniuse.com/rtcpeerconnection" rel="noopener noreferrer"&gt;source&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Bad side
&lt;/h3&gt;

&lt;p&gt;Require a singling server&lt;/p&gt;

&lt;p&gt;complex API compared to WebSockets, but many packages work toward solving that.&lt;/p&gt;

&lt;h2&gt;
  
  
  When should you use WebRTC instead of a WebSocket?
&lt;/h2&gt;

&lt;p&gt;Rarely. That's the truth.&lt;/p&gt;

&lt;p&gt;If you're contemplating between the two and you don't know a lot about WebRTC, then you're probably in need of WebSockets, or will be better off using WebSockets.&lt;/p&gt;

&lt;p&gt;I think of data channels either when there are things you want to pass directly across browsers without any server intervention in the message itself (and these use cases are quite scarce), or you need a low latency messaging solution across browsers where a relay via a WebSocket will be too time-consuming.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources time:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://bloggeek.me/webrtc-vs-websockets/#:~:text=WebRTC%20doesn't%20use%20WebSockets,as%20HTTPS%20or%20secure%20WebSockets." rel="noopener noreferrer"&gt;WebRTC vs WebSockets BlogGeek.me&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/aljanabim/simple_webrtc_signaling_server" rel="noopener noreferrer"&gt;Simple WebRTC Signaling Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.google.com/document/d/1idl_NYQhllFEFqkGQOLv8KBK8M3EVzyvxnKkHl4SuM8/edit#heading=h.catfe7kt7q0m" rel="noopener noreferrer"&gt;WebRTC and Web Audio Resources&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>learning</category>
    </item>
    <item>
      <title>How to Get Slack Notifications on Your GitHub</title>
      <dc:creator>Amr Hassan</dc:creator>
      <pubDate>Fri, 30 Sep 2022 10:48:35 +0000</pubDate>
      <link>https://dev.to/amrh434/how-to-get-slack-notifications-on-your-github-18pn</link>
      <guid>https://dev.to/amrh434/how-to-get-slack-notifications-on-your-github-18pn</guid>
      <description>&lt;p&gt;You probably know that GitHub has an &lt;a href="https://github.com/integrations/slack"&gt;application&lt;/a&gt; that you can add to your slack workspace.&lt;/p&gt;

&lt;p&gt;While this app is nice and dandy if you want to get notified about *&lt;em&gt;all *&lt;/em&gt; actions that happen on GitHub and keep subscribing and unsubscribing to the repositories you are interested in and could even make it publish reminders on a specific channel but it is very noisy.&lt;/p&gt;

&lt;p&gt;After digging more into Github, you can find an exciting feature &lt;strong&gt;(scheduled reminders)&lt;/strong&gt; that could enable you only to get notified for the PR you are requested to review, replies to your comments, or even commits...etc.&lt;br&gt;
In real-time or a timed reminder which is something essential to have if you don't want to miss a single PR or be late on reviewing, so buckle up because I'm gonna walk you step by step on how to do it.&lt;/p&gt;

&lt;p&gt;But before all of that make sure that you have admin permission on your GitHub organization or know someone who can allow the Github application to read your repositories info.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open your profile, then click on settings&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tjy2Chnn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/opb0pjl96rtwsa668vg1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tjy2Chnn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/opb0pjl96rtwsa668vg1.png" alt="Image description" width="274" height="707"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scroll down till you find scheduled reminders&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qTi-_bhF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hj727uwwd02febxq6np2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qTi-_bhF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hj727uwwd02febxq6np2.png" alt="Image description" width="880" height="299"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the organization that you want to get reminders for&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IjC7BiTy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4hkafc5371enpf286k9t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IjC7BiTy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4hkafc5371enpf286k9t.png" alt="Image description" width="880" height="125"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Authorize the app, &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nwFTaUvM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p3qrb7eddup755jvqjhx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nwFTaUvM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p3qrb7eddup755jvqjhx.png" alt="Image description" width="713" height="621"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zX9Z9dX0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3w11709n5xzwlhyorl9d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zX9Z9dX0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3w11709n5xzwlhyorl9d.png" alt="Image description" width="676" height="901"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;you can allow the application to read specific repositories instead of all by clicking on only select repositories.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure the reminder to your liking&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XUlw-IfG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdvyajadovr25y2aqxiw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XUlw-IfG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdvyajadovr25y2aqxiw.png" alt="Image description" width="880" height="736"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the ideal setup for me &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rcSphdoG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9zcvegoanlzd1qtifk8h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rcSphdoG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9zcvegoanlzd1qtifk8h.png" alt="Image description" width="880" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Bouns tip
&lt;/h3&gt;

&lt;p&gt;You can test your reminder by clicking on the below icon inside the &lt;strong&gt;scheduled reminders&lt;/strong&gt; tap&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0AzxY8lF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i7eli3o7gpovrlr8sb88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0AzxY8lF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i7eli3o7gpovrlr8sb88.png" alt="Image description" width="880" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Message queues: SQS vs Kafka</title>
      <dc:creator>Amr Hassan</dc:creator>
      <pubDate>Fri, 23 Sep 2022 23:13:31 +0000</pubDate>
      <link>https://dev.to/amrh434/message-queues-sqs-vs-kafka-4fod</link>
      <guid>https://dev.to/amrh434/message-queues-sqs-vs-kafka-4fod</guid>
      <description>&lt;h2&gt;
  
  
  Message queue battle royal SQS vs Kafka
&lt;/h2&gt;

&lt;p&gt;Kafka and SQS are very popular message queues, for Kafka, it's a huge scale and operational pain, SQS with plug and play and far far less operational pain.&lt;/p&gt;

&lt;p&gt;It becomes harder to choose which one to use as a developer, as a developer we will always choose the laziest approach which is SQS due to the soft process of just clicking here, and their boof you have a message queue.&lt;/p&gt;

&lt;p&gt;When actually picking one on top of another I mean we all know that Kafka is a bit complex compared to SQS, in terms of having many brokers and partitions, replicas, and topics while in SQS you only need to specify your queue name and just publish and consume from it.&lt;/p&gt;

&lt;p&gt;But there is more to it than the operational and development cost, what I noticed throughout my work with both is that Kafka is more oriented to handle the notion of many consumers &amp;amp; events is that the publisher needs to be aware of the consumer which starts having an unhealthy pattern of smart publisher that adjust the messages for each consumer, which is kinda bad as it makes the relation between publisher and consumer more coupled and strict.&lt;/p&gt;

&lt;p&gt;To elaborate that more let's lead with a story,&lt;br&gt;
So let's assume that we have a delivery system where we have many domains let's only focus on the order domain, at first we need to notify the user whenever the order is on its way, and we define that by a field status over the order's domain.&lt;/p&gt;

&lt;p&gt;Now we can choose whether the order domain operation is a single queue/topic or each status is a different queue/topic.&lt;br&gt;
Let's go with a single queue/topic for all order operations called &lt;code&gt;orders&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d-0Zswpd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1663425153434/py7KCoXMh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d-0Zswpd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1663425153434/py7KCoXMh.jpg" alt="Untitled (1).jpg" width="880" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far there is no difference between Kafka &amp;amp; SQS.&lt;/p&gt;

&lt;p&gt;Time passes and we needed to start measuring how long it takes for the order to be delivered compared to our initial estimation which is again with the status thing but different consumer this time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--keEUWRC9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1663973082516/T63x1tanB.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--keEUWRC9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1663973082516/T63x1tanB.jpg" alt="Untitled (5).jpg" width="880" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;SQS vs Kafka&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;With Kafka, it's very easy to add a new consumer over our &lt;code&gt;orders&lt;/code&gt; topic using the consumer group notion, but for SQS it would be a new queue.&lt;br&gt;
This also makes the order service know who are the consumers and what they need so every time we need to do something different with the orders we will need to modify the &lt;code&gt;orders service&lt;/code&gt; to publish to a different topic as well as integrate a new different queue config.&lt;/p&gt;

&lt;p&gt;This is the reason why I don't like the usage of SQS with a domain that requires many events.&lt;/p&gt;

&lt;p&gt;Let me know what you think of that in the comments below&lt;/p&gt;

</description>
      <category>kafka</category>
      <category>sqs</category>
      <category>messagequeues</category>
    </item>
    <item>
      <title>When To Go Serverless?</title>
      <dc:creator>Amr Hassan</dc:creator>
      <pubDate>Thu, 27 Jan 2022 16:19:05 +0000</pubDate>
      <link>https://dev.to/amrh434/when-to-go-serverless-j02</link>
      <guid>https://dev.to/amrh434/when-to-go-serverless-j02</guid>
      <description>&lt;p&gt;I'm sure now most of you, if not all, have heard about serverless and how trendy &amp;amp; sexy it's. But what bothered me the most was when to use one?&lt;/p&gt;

&lt;p&gt;But before answering that, let’s answer the what &amp;amp; why first and by knowing that the answer will reveal itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Serverless?
&lt;/h2&gt;

&lt;p&gt;So what is serverless? Does it mean that there is no server? Nope, that's not the case. It means that you are not responsible for managing your infrastructure. All you have to do is write some logic to be executed when a certain something happens. Certain something could be an event, for example, a file uploaded or an HTTP call.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Serverless?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Scaling/unpredictable workload.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While the scaling point could be achieved by many solutions already, for example, Kubernetes with KDA could do the same effect, but again most of the cloud providers will provide this functionality out of the box and will be more efficient as you are only paying for the resources you used.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cost&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Theoretically speaking, cost should be very low as you are only paying for what you use, meaning the function would only work when some sort of event happens, and you are only paying for the time the function took to finish the work.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simplicity/Rapid development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You only care about your business logic. Everything else is not your responsibility, no server, no number of replicas, nothing you want to do 1 2 3 just write 1 2 3.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's easy to apply a principle such as least privilege where you define the permissions for each function so that there is no such master function (you shouldn't have) that does it all and have permission for everything besides that the cloud provider should provide the latest updated versions of OS that runs your function so you shouldn't worry about that.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bad side?
&lt;/h2&gt;

&lt;p&gt;What are the limitations?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cold Start&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The time the cloud provider takes to lunch your function, and it depends on how frequent the function was called sometimes, it takes 1 - 2s.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can't store things in memory/files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When your function gets triggered, it runs on an ephemeral disk which is something that gets deleted after the function completes. The same thing applies to the used memory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Execution time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some cloud providers limit your function running time to a certain number of minutes, so if you want to process something that takes a long time, it’s a big no.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vendor lockin&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This happens when your implementation &amp;amp; logic rely on the infrastructure of a specific cloud provider. For example, if you are using AWS, you will end up relying on many services &amp;amp; permission related only to AWS, which means if you want to switch to another cloud provider, you will suffer a little.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hard to test&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While frameworks such as serverless &amp;amp; SAM could allow you to run your function offline, your function won’t run without storage or a database. So you will end up using some resources in the process and maybe cost you a bit compared to the normal way.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to go serverless?
&lt;/h2&gt;

&lt;p&gt;Now, this is a hard question to answer. For me, it depends on the problem you are trying to resolve, so if you are doing a time-consuming task, most likely using functions won’t be good enough for you the same thing for handling real-time apps.&lt;/p&gt;

&lt;p&gt;On the other hand, if you want something rapid to develop and you are short on the money side, this is definitely something to consider.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Localizing your android app</title>
      <dc:creator>Amr Hassan</dc:creator>
      <pubDate>Wed, 03 Nov 2021 15:23:34 +0000</pubDate>
      <link>https://dev.to/amrh434/localizing-your-android-app-37gg</link>
      <guid>https://dev.to/amrh434/localizing-your-android-app-37gg</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Following up on what we did last time &lt;a href="https://dev.to/amrh434/introduction-to-android-project-structure-g3g"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Our application started to have different audiences with different languages, so we want to localize our app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;p&gt;The good thing is that we have a few texts to change and we already using a reference to the &lt;code&gt;strings.xml&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
file located in::  src/main/res/layout
*/
android:text="@string/my_button_text"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which have this value&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
file located in:: src/main/res/values/strings.xml
*/
&amp;lt;resources&amp;gt;
    ...
    &amp;lt;string name="my_button_text"&amp;gt;Click!&amp;lt;/string&amp;gt;
&amp;lt;/resources&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Update all the text inside your app to use &lt;code&gt;strings.xml&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;We also have the text we use for the toast inside our &lt;code&gt;MainActivity.java&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Toast.makeText(getApplicationContext(), "Clicked!!", Toast.LENGTH_SHORT).show();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So first thing first let's use the &lt;code&gt;strings.xml&lt;/code&gt; instead of having the text inside the main file by doing the following update the &lt;code&gt;strings.xml&lt;/code&gt; to have a text for the toast&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
file located in:: src/main/res/values/strings.xml
*/
&amp;lt;resources&amp;gt;
 ...
    &amp;lt;string name="toast_text"&amp;gt;Clicked!!&amp;lt;/string&amp;gt;
&amp;lt;/resources&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and update the &lt;code&gt;MainActivity.java&lt;/code&gt; file to use the new text&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Toast.makeText(getApplicationContext(), R.string.toast_text,Toast.LENGTH_SHORT).show();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we updated all the texts around our App to use the &lt;code&gt;strings.xml&lt;/code&gt; values.&lt;/p&gt;

&lt;h3&gt;
  
  
  It's time to translate our &lt;code&gt;strings.xml&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Right-click on the &lt;code&gt;strings.xml&lt;/code&gt;, select the Open Translations Editor&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y52j42gq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1635950530536/A9FqoaiC7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y52j42gq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1635950530536/A9FqoaiC7.png" alt="Untitled111.png" width="880" height="993"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, you would need to click on the globe icon, to choose the language you want to support, I'll choose Arabic&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xKPNDrdR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1635950754189/51YAXZA70.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xKPNDrdR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1635950754189/51YAXZA70.png" alt="Untitled111.png" width="743" height="68"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The last thing is to fill in the values for each text &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D-GI_vOz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1635951092456/PxwJb9qh7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D-GI_vOz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1635951092456/PxwJb9qh7.png" alt="Untitled.png" width="880" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the android studio will generate a new strings.xml file for the language you just selected. &lt;/p&gt;

&lt;p&gt;Here is the result&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rzq0hMMU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1635951519756/wCXHVO7vu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rzq0hMMU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1635951519756/wCXHVO7vu.png" alt="download (1).png" width="880" height="777"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Congrats!!&lt;/strong&gt; now you can support any language you want and have more audience around the globe&lt;/p&gt;

&lt;p&gt;See you in the next part&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@dollargill?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Dollar Gill&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/android?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>android</category>
    </item>
    <item>
      <title>Introduction to android - project structure</title>
      <dc:creator>Amr Hassan</dc:creator>
      <pubDate>Thu, 21 Oct 2021 21:13:15 +0000</pubDate>
      <link>https://dev.to/amrh434/introduction-to-android-project-structure-g3g</link>
      <guid>https://dev.to/amrh434/introduction-to-android-project-structure-g3g</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The point of this article is to give you an idea about the android project structure.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Are you ready, It's time for a story, we want to build an application with a single page that has a single button, and whenever you click on that button it gives the user a feedback msg that the button was clicked.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So you start by creating an android project with empty activity over &lt;a href="https://developer.android.com/studio" rel="noopener noreferrer"&gt;android studio&lt;/a&gt; but a wild project hierarchy shows up&lt;/p&gt;

&lt;h2&gt;
  
  
  Android project hierarchy
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1634506139037%2FzijiobiXD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1634506139037%2FzijiobiXD.png" alt="android-project-folders.png"&gt;&lt;/a&gt;&lt;br&gt;
Here are the most used folders&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://developer.android.com/guide/topics/manifest/manifest-intro" rel="noopener noreferrer"&gt;manifests&lt;/a&gt; &lt;code&gt;(you can specify the permissions here, your package name is defined here, every activity, service, everything needs to be mentioned here )&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;java/your-package &lt;code&gt;(contains your logic, staff like what you want to do when the user opens the app, click on the button...etc)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;res

&lt;ul&gt;
&lt;li&gt;drawable &lt;code&gt;(Contains logo, images)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;layout &lt;code&gt;(Your pages design and content)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;values &lt;code&gt;(any description, the title basically any text on the UI should be written here &amp;amp; referenced in the layouts)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;build.gradle (Module) &lt;code&gt;(The place where you set your dependencies, add different build types, versioning your builds)&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of course, there are other folders &amp;amp; files but these are the ones that you are going to deal with the most.&lt;/p&gt;
&lt;h2&gt;
  
  
  The run flow
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1634507871676%2FLOKCfQCJH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1634507871676%2FLOKCfQCJH.png" alt="activity_lifecycle.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Image &lt;a href="https://developer.android.com/guide/components/activities/activity-lifecycle" rel="noopener noreferrer"&gt;source&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When you run the app, the first thing execute is the &lt;code&gt;MainActivity&lt;/code&gt;, and any activity has the above lifecycle where it calls &lt;code&gt;onCreate()&lt;/code&gt; at the beginning, so there where we will find the main layout rendering.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which in return start rendering the mentioned layout inside the &lt;code&gt;/res/layout&lt;/code&gt; folder where it contains something similar to this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"&amp;gt;

     &amp;lt;Button
        android:id="@+id/my_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/my_button_text"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
         /&amp;gt;

&amp;lt;/androidx.constraintlayout.widget.ConstraintLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Notice this line&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;androidx.constraintlayout.widget.ConstraintLayout  .....&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It says &lt;code&gt;contraintLayout&lt;/code&gt; can you guess what it might imply? it implies that there are different layouts.&lt;br&gt;
So what are they? and which one you should use?&lt;br&gt;
There are many layouts for example&lt;br&gt;
StackLayout, RelativeLayout, GridLayout...etc&lt;br&gt;
each one has its own use cases.&lt;br&gt;
But if you have a large and complex design with some sort of relationship between sibling views and parent layout then &lt;code&gt;contraintLayout&lt;/code&gt; is the one for you.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;for example, if you want to position a text at the middle of the view you can just add to the element definition&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Notice this line&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  android:text="@string/my_button_text"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will use the value defined in &lt;code&gt;values/strings.xml&lt;/code&gt; as long as it has the same name and type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;string name="my_button_text"&amp;gt;Click!&amp;lt;/string&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means when the view renders it will show a button with the text Click!&lt;/p&gt;

&lt;p&gt;As you can see the layout has the button defined, but we need to add a click listener over the button so that when the user click it we can do something and that's when this  &lt;code&gt;android:id="@+id/my_button"&lt;/code&gt; attribute over the button come in handy so in the &lt;code&gt;MainActivity&lt;/code&gt; inside the &lt;code&gt;onCreate&lt;/code&gt; Method we can say&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Button bt = findViewById(r.id.my_button);
bt .setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getApplicationContext(), "Clicked!!", Toast.LENGTH_SHORT).show();
            }
        });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way whenever the button with key &lt;code&gt;android:id="@+id/my_button"&lt;/code&gt; is clicked the func onClick will be executed&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Congrats!!&lt;/strong&gt; you finished the story and you have a button that whenever clicked will show a message.&lt;/p&gt;

&lt;p&gt;See you in the next part&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Cover photo by &lt;a href="https://unsplash.com/@vork?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Mark Boss&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/android?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>android</category>
      <category>java</category>
    </item>
    <item>
      <title>Kubernetes namespaces you should never miss with.</title>
      <dc:creator>Amr Hassan</dc:creator>
      <pubDate>Tue, 19 Oct 2021 21:17:15 +0000</pubDate>
      <link>https://dev.to/amrh434/kubernetes-namespaces-you-should-never-miss-with-1idh</link>
      <guid>https://dev.to/amrh434/kubernetes-namespaces-you-should-never-miss-with-1idh</guid>
      <description>&lt;p&gt;Kubernetes is shipped with many namespaces some of them are critical for Kubernetes in order to function correctly.&lt;br&gt;
Messing around in one of these namespaces can damage the Kubernetes system.&lt;/p&gt;

&lt;p&gt;And these are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;default&lt;/code&gt; the home of the homeless&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kube-system&lt;/code&gt; The namespace for objects created by the Kubernetes system&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kube-public&lt;/code&gt; This namespace is created automatically and is readable by all users (including those not authenticated). This namespace is mostly reserved for cluster usage, in case that some resources should be visible and readable publicly throughout the whole cluster. This is useful for exposing any cluster information necessary to bootstrap components. It is primarily managed by Kubernetes itself.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kube-node-lease&lt;/code&gt; This namespace holds Lease objects associated with each node. Node leases allow the kubelet to send heartbeats so that the control plane can detect node failure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All Kubernetes system's namespaces will be regenerated again even when you delete them accidentally that's what Kubernetes components will try to do.&lt;/p&gt;

&lt;p&gt;But sometimes if you are unfortunate enough deleting namespaces might be stuck at the terminating stage giving no option to regenerate the namespace again.&lt;/p&gt;

&lt;p&gt;So the below cases mention what is the importance of each namespace in order to know what the symptoms might look like.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is the &lt;code&gt;default&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;default&lt;/code&gt; namespace is used as the default place of any objects you create with no namespace specified.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is the &lt;code&gt;kube-system&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Kube-system&lt;/code&gt; is the namespace for objects and service accounts with high-level privileges within Kubernetes. Utilization of the Kubernetes controller stems from this namespace, in other words we will have some issues with the controllers and maybe in deploying new pods/deployment.&lt;/p&gt;

&lt;p&gt;not only that this namespace also contains other important objects such as &lt;code&gt;kube-dns&lt;/code&gt;,&lt;code&gt;kube-proxy&lt;/code&gt;,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kube-dns&lt;/code&gt; is the authoritative name server for the cluster domain (cluster.local) and it resolves external names recursively. Short names that are not fully qualified, such as myservice, are completed first with local search paths. more details &lt;a href="https://cloud.google.com/kubernetes-engine/docs/how-to/kube-dns"&gt;here&lt;/a&gt; &amp;amp; &lt;a href="https://www.digitalocean.com/community/tutorials/an-introduction-to-the-kubernetes-dns-service"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kube-proxy&lt;/code&gt; manages the forwarding of traffic addressed to the virtual IP addresses (VIPs) of the cluster’s Kubernetes Service objects to the appropriate backend pods more details &lt;a href="https://www.tigera.io/blog/comparing-kube-proxy-modes-iptables-or-ipvs/"&gt;here&lt;/a&gt; &amp;amp; &lt;a href="https://arthurchiao.art/blog/cracking-k8s-node-proxy/"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This means you will have trouble with resolving external/internal communications.&lt;/p&gt;
&lt;h3&gt;
  
  
  How about the &lt;code&gt;kube-public&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;kube-public&lt;/code&gt; contains a single ConfigMap object, cluster-info, that aids discovery and security bootstrap.&lt;/p&gt;

&lt;p&gt;All the above namespaces if you tried to delete them the server will respond with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error from server (Forbidden): namespaces "kube-public" is forbidden: this namespace may not be deleted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expect the lucky &lt;code&gt;kube-node-release&lt;/code&gt; which was added in Kubernetes v1.14, would get deleted the same as any normal namespace.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is &lt;code&gt;kube-node-release&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;kube-node-lease&lt;/code&gt; This namespace holds Lease objects associated with each node. Node leases allow the kubelet to send heartbeats so that the control plane (Node controller) can detect node failure.&lt;/p&gt;

&lt;p&gt;So what would happen if we deleted &lt;code&gt;kube-node-lease&lt;/code&gt;? usually, Kubernetes will create another one with Lease object for each node, but sometimes the namespace removal gets stuck at the &lt;code&gt;terminating&lt;/code&gt; status.&lt;br&gt;
Which by then we will have a node Lease with an outdated heartbeat which might tell the Node controller that this node is not reachable and impact the overall communication between the nodes.&lt;/p&gt;
&lt;h3&gt;
  
  
  How to fix namespace removal stuck at &lt;code&gt;terminating&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;Of course, you can try to figure out why the namespace is stuck at terminating but sometimes you can't so here we go with the &lt;strong&gt;force delete&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1-  create a temp json file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; kubectl get namespace &amp;lt;terminating-namespace&amp;gt; -o json &amp;gt;tmp.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2-  execute the below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl proxy
Starting to serve on 127.0.0.1:8001
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3-  Edit your tmp.json file. Remove the Kubernetes value from the finalizers field and save the file.&lt;/p&gt;

&lt;p&gt;4-  Make the below command to update the namespace&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/&amp;lt;terminating-namespace&amp;gt;/finalize
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5-  Your output will look something like the one below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "kind": "Namespace",
   "apiVersion": "v1",
   "metadata": {
     "name": "&amp;lt;terminating-namespace&amp;gt;",
     "selfLink": "/api/v1/namespaces/&amp;lt;terminating-namespace&amp;gt;/finalize",
     "uid": "b50c9ea4-ec2b-11e8-a0be-fa163eeb47a5",
     "resourceVersion": "1602981",
     "creationTimestamp": "2021-10-18T18:48:30Z",
     "deletionTimestamp": "2021-10-18T18:59:36Z"
   },
   "spec": {

   },
   "status": {
     "phase": "Terminating"
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>kubernetes</category>
      <category>cloud</category>
      <category>devops</category>
      <category>sre</category>
    </item>
  </channel>
</rss>
