<?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: Tsuyoshi Chujo</title>
    <description>The latest articles on DEV Community by Tsuyoshi Chujo (@chooyan).</description>
    <link>https://dev.to/chooyan</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%2F54431%2F3f600d7c-4522-477e-a84b-1310891061c5.jpg</url>
      <title>DEV Community: Tsuyoshi Chujo</title>
      <link>https://dev.to/chooyan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chooyan"/>
    <language>en</language>
    <item>
      <title>Crop images with your own designed UI using "crop_your_image" Flutter package</title>
      <dc:creator>Tsuyoshi Chujo</dc:creator>
      <pubDate>Tue, 16 Mar 2021 13:00:54 +0000</pubDate>
      <link>https://dev.to/chooyan/crop-images-with-your-own-designed-ui-using-cropyourimage-flutter-package-ci7</link>
      <guid>https://dev.to/chooyan/crop-images-with-your-own-designed-ui-using-cropyourimage-flutter-package-ci7</guid>
      <description>&lt;p&gt;When you are thinking of building functionality to crop images in your Flutter app, you would search &lt;a href="https://pub.dev/" rel="noopener noreferrer"&gt;pub.dev&lt;/a&gt; and find several Flutter packages, such as &lt;a href="https://pub.dev/packages/image_crop" rel="noopener noreferrer"&gt;image_crop&lt;/a&gt;, &lt;a href="https://pub.dev/packages/image_cropper" rel="noopener noreferrer"&gt;image_cropper&lt;/a&gt;, etc. &lt;/p&gt;

&lt;p&gt;In this article, I would like to give you one more choice here, &lt;br&gt;
&lt;a href="https://pub.dev/packages/crop_your_image" rel="noopener noreferrer"&gt;crop_your_image&lt;/a&gt; which is developed by &lt;a href="https://github.com/chooyan-eng" rel="noopener noreferrer"&gt;ME&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;
  
  
  What is crop_your_image
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://pub.dev/packages/crop_your_image" rel="noopener noreferrer"&gt;crop_your_image&lt;/a&gt; is a Flutter package which enables you app developers to embed functionality of cropping images in your apps: typically needed in "Edit Profile Image" pages or "Upload Image" pages, etc.&lt;/p&gt;

&lt;p&gt;Though I know we already have some nice package to build such pages, I believe one more package with different approach would help someone who are not satisfied in existing packages.&lt;/p&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%2Fgithub.com%2Fchooyan-eng%2Fcrop_your_image%2Fblob%2Fmain%2Fassets%2Fcropyourimage.gif" 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%2Fgithub.com%2Fchooyan-eng%2Fcrop_your_image%2Fblob%2Fmain%2Fassets%2Fcropyourimage.gif" alt="crop_your_image demo"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  crop_your_image's Approach
&lt;/h1&gt;

&lt;p&gt;The biggest policy of crop_your_image package is &lt;em&gt;provide controller, not UI&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;As far as I have researched, most image cropping package provides both cropping feature and UI to determine the area of cropping images.&lt;/p&gt;

&lt;p&gt;Yeah, it would be quite helpful as app developers can embed image cropping functionality into their apps with only writing a couple of lines of codes.&lt;/p&gt;

&lt;p&gt;On the other hand, however, I also believe that some need to build such functionality &lt;em&gt;with their own UI designed with their own brand image&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Considering that kind of use-cases, providing fixed UI, even though the UI can be customized by passing parameters to change color, text, size, etc., prevent app developers from keep consistency of UI design.&lt;/p&gt;

&lt;p&gt;crop_your_image's approach is to provide &lt;code&gt;Crop&lt;/code&gt; widget which is controlled by using &lt;code&gt;CropController&lt;/code&gt; and DON'T provides Widgets to manage this controller. For example, you can just call &lt;code&gt;CropController.crop&lt;/code&gt; method from your own Widget to execute cropping images with rect that user selected.&lt;/p&gt;
&lt;h1&gt;
  
  
  Sample program
&lt;/h1&gt;

&lt;p&gt;Here is some sample programs.&lt;/p&gt;

&lt;p&gt;What app developers have to do is simply place &lt;code&gt;Crop&lt;/code&gt; widget at wherever on the widget tree they want to place.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nd"&gt;@override&lt;/span&gt;
&lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;width:&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;infinity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;infinity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Crop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;image:&lt;/span&gt; &lt;span class="n"&gt;_originalImage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;onCropped:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;croppedImage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// do whatever you want with cropped image&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;image&lt;/code&gt; property is an original image data with type of &lt;code&gt;Uint8List&lt;/code&gt;, which can be from image file in assets folder or from network possibly depending on each apps' implementation.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Crop&lt;/code&gt; widget will display the given image and interactively resizable cropping area on users' screen.&lt;/p&gt;

&lt;p&gt;Once image is cropped, &lt;code&gt;onCropped&lt;/code&gt; callback is called with cropped image data with type of &lt;code&gt;Uint8List&lt;/code&gt; also.&lt;/p&gt;

&lt;p&gt;But how to execute cropping? &lt;code&gt;CropController&lt;/code&gt; is available here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nd"&gt;@override&lt;/span&gt;
&lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CropController&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;width:&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;infinity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;infinity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Crop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;image:&lt;/span&gt; &lt;span class="n"&gt;_originalImage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;onCropped:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;croppedImage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// do whatever you want with cropped image&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="nl"&gt;controller:&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;CropController&lt;/code&gt; has several methods such as &lt;code&gt;crop()&lt;/code&gt; to execute cropping the image with currently selected area, or &lt;code&gt;cropCircle()&lt;/code&gt; if you want images cropped with circle shape. &lt;/p&gt;

&lt;p&gt;What app developer do is just call the methods at anywhere like &lt;code&gt;onPressed&lt;/code&gt; callback of &lt;code&gt;ElevatedButton&lt;/code&gt; like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;ElevatedButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Crop it!'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;crop&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;span class="p"&gt;),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As &lt;code&gt;ElevatedButton&lt;/code&gt; is a widget provided by flutter framework and can be designed whatever you like, app developers can embed &lt;code&gt;Crop&lt;/code&gt; widget of crop_your_image without breaking the consistency of your own design.&lt;/p&gt;

&lt;h1&gt;
  
  
  Other Features
&lt;/h1&gt;

&lt;p&gt;crop_your_image has more features such as fixing aspect ratio, cropping with circle shape, etc. and the details are explained on README.md of the package.&lt;/p&gt;

&lt;p&gt;Because crop_your_image is just started developing a couple of days ago, new features can be added day by day.&lt;/p&gt;

&lt;p&gt;If you are interested in the package and need features that are not implemented yet, I'm looking forward to receive issues or comments on &lt;a href="https://github.com/chooyan-eng/crop_your_image" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;crop_your_image is a brand-new (meaning still alpha) Flutter package that provides "cropping images" functionality to your apps.&lt;/p&gt;

&lt;p&gt;Comparing to existing packages, crop_your_image provides minimum UI so that app developers can embed &lt;code&gt;Crop&lt;/code&gt; widget keeping consistency of UI design.&lt;/p&gt;

&lt;p&gt;crop_your_image also available on multi-platforms because it does NOT use native code (Swift / Kotlin) via PlatformChannel and depend only on &lt;a href="https://pub.dev/packages/image" rel="noopener noreferrer"&gt;image&lt;/a&gt; package which is 100% built with Dart.&lt;/p&gt;

&lt;p&gt;I'll be very happy if you try crop_your_image and give me any feedback. Thanks.&lt;/p&gt;




&lt;p&gt;Thank you for reading my introduction to crop_your_image Flutter package.&lt;/p&gt;

&lt;p&gt;As I'm not a native speaker of English, some expression would be strange and give you confusion, I guess. If you have anything unclear, just leave comments below and I’m glad to discuss.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>package</category>
      <category>privateproject</category>
    </item>
    <item>
      <title>Do you code `if (foo == true) ` in Java?</title>
      <dc:creator>Tsuyoshi Chujo</dc:creator>
      <pubDate>Tue, 20 Feb 2018 09:23:31 +0000</pubDate>
      <link>https://dev.to/chooyan/do-you-code-if-foo--true--in-java--4imn</link>
      <guid>https://dev.to/chooyan/do-you-code-if-foo--true--in-java--4imn</guid>
      <description>&lt;p&gt;There posted the discussion that "Do you code &lt;code&gt;if (foo == true)&lt;/code&gt; in Java?" on Qiita, Japanese tech blog. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://qiita.com/ikemo/items/4f56a283f9e27cf98d81"&gt;https://qiita.com/ikemo/items/4f56a283f9e27cf98d81&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The auther argues that it's "No" because its verbose (&lt;code&gt;if (foo)&lt;/code&gt; is enough), it may cause typo that &lt;code&gt;if (foo = true)&lt;/code&gt; and it would increase the number of steps and run slower.&lt;/p&gt;

&lt;p&gt;So, the code should be like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// do something&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;isBuzz&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getFoo&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;getBar&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;isBuzz&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// do something&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;and not&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;foo&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// do something&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getFoo&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;getBar&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// do something&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, there posted many counter arguments that &lt;code&gt;!&lt;/code&gt; operator can be easily overlooked, &lt;code&gt;== true&lt;/code&gt; is easy to understand, both ways are acceptable, etc.&lt;/p&gt;

&lt;p&gt;Basically, I'm for the author's opinion. &lt;code&gt;== true&lt;/code&gt; doesn't provide any advantage for readability and simply &lt;code&gt;if (isSuccessful())&lt;/code&gt; is comfortable to pronounce.&lt;/p&gt;

&lt;p&gt;How do you think of this?&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>java</category>
      <category>programming</category>
    </item>
    <item>
      <title>How Do You Teach Yourself After Reading Books for Beginners?</title>
      <dc:creator>Tsuyoshi Chujo</dc:creator>
      <pubDate>Thu, 25 Jan 2018 10:09:31 +0000</pubDate>
      <link>https://dev.to/chooyan/how-do-you-teach-yourself-after-reading-books-for-beginners-2din</link>
      <guid>https://dev.to/chooyan/how-do-you-teach-yourself-after-reading-books-for-beginners-2din</guid>
      <description>&lt;p&gt;When thinking about the situation that you are willing to work with a programming language which is new to you, what will you do to teach yourself?&lt;/p&gt;

&lt;p&gt;Most of you will read some books written for beginners, or will go to some tutorial site of the language. You may sign up to some code challenge sites such as &lt;a href="https://www.codewars.com/"&gt;codewars&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I am totally positive to do so and I do too. However, even if you finish everything above, you may still be worrying that "Can I do well with this knowledge in the real job?"&lt;/p&gt;

&lt;p&gt;Now, I would like to ask yow how do you teach yourself after finishing those works for beginners.&lt;/p&gt;

&lt;h1&gt;
  
  
  Code Reviewing
&lt;/h1&gt;

&lt;p&gt;I will introduce my answer to the question above, that is to ask someone, who are working with Ruby already, to review your code and discuss what code is nice and what code is not looking at YOUR code.&lt;/p&gt;

&lt;p&gt;In the job, it is extremely important that you can explain why you wrote this code, because there is no absolutely nice code.&lt;/p&gt;

&lt;p&gt;What programmers have to do in the real work is to think of the best code within the specific situation you are facing, and what beginners have to learn is how  they write suitable codes considering each situations.&lt;/p&gt;

&lt;p&gt;The problem here is that we need experiences for "considering each situations", which beginners don't have of course. Thus, code reviewing and feedback from the experienced is necessary.&lt;/p&gt;

&lt;h1&gt;
  
  
  CodeYourRuby
&lt;/h1&gt;

&lt;p&gt;I would like to introduce &lt;a href="https://github.com/chooyan-eng/code-your-ruby"&gt;CodeYourRuby&lt;/a&gt; which I opened as a GitHub repository.&lt;/p&gt;

&lt;p&gt;CodeYourRuby is a place where beginners of Ruby can ask the experienced Rubyists to review their code.&lt;/p&gt;

&lt;p&gt;By making Pull Requests of codes which satisfy the &lt;a href="https://github.com/chooyan-eng/code-your-ruby/tree/master/specification"&gt;specifications of assessments&lt;/a&gt; committed to CodeYourRuby repository, the experienced Rubyists review them on the Pull Requests by practical point of view.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits for beginners
&lt;/h2&gt;

&lt;p&gt;As mentioned above, the Ruby learners can discuss with the experienced Rubyist looking at the same code, yours, and the discussion will make them think about and know nice Ruby-like code more and more. That is the biggest benefit for beginners.&lt;/p&gt;

&lt;p&gt;The assessments are not very complicated, which can be implemented with a couple of classes and tests, so they can easily start coding, but not too easy to finish in a couple of minutes or so.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits for reviewers
&lt;/h2&gt;

&lt;p&gt;You may think that who, the experienced Rubyists, would join CodeYourRuby as a volunteer. Yeah, it's true that CodeYourRuby has one big problem that it doesn't have enough reviewers and Pull Requests are left without any comments.&lt;/p&gt;

&lt;p&gt;However, that does not mean reviewing on CodeYourRuby is meaningless for reviewers.&lt;/p&gt;

&lt;p&gt;Reviewers can discuss with other reviewers. By discussing with not only the beginners but also the other experienced Rubyists, they can find new knowledges or ideas about Ruby. As they cannot say they know everything about ruby, it is useful to join the discussion.&lt;/p&gt;

&lt;p&gt;In addition, especially for those who does NOT have enough chance to be a reviewer in their job, CodeYourRuby is the awesome place to practice reviewing.&lt;/p&gt;

&lt;p&gt;Therefore, even if they have already worked with Ruby and familiar with Ruby, joining code reviews on CodeYourRuby will work them positively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;As I discussed so far, joining code reviews is very important for both the beginners and the experienced.&lt;/p&gt;

&lt;p&gt;CodeYourRuby can provide chances of code reviews for everyone for free if they are looking for ones.&lt;/p&gt;

&lt;p&gt;As the idea of CodeYourRuby can be reusable with some other language or some other community, I will be happy if repositories with the idea of CodeYourRuby are created more and more. Also, I will be happy if more and more Rubyists join discussions on CodeYourRuby.&lt;/p&gt;

&lt;p&gt;* Note that CodeYourRuby is only for Japanese right now. I will work hard for translation if I get a lot of positive responses from the readers of this post. (So I'll be grad if you "like" this post or "star" CodeYourRuby repository, thanks.)&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Understand the basic idea of HTTP based on TCP</title>
      <dc:creator>Tsuyoshi Chujo</dc:creator>
      <pubDate>Wed, 24 Jan 2018 08:20:14 +0000</pubDate>
      <link>https://dev.to/chooyan/understand-the-basic-idea-of-http-based-on-tcp-3i5j</link>
      <guid>https://dev.to/chooyan/understand-the-basic-idea-of-http-based-on-tcp-3i5j</guid>
      <description>&lt;p&gt;HTTP is the most used technology now and indispensable for all the web services.&lt;/p&gt;

&lt;p&gt;We can easily send HTTP requests with HTTP client libraries we like, or can easily run HTTP servers with whatever languages and frameworks we like. We don't need to think about what is happening in the libraries or frameworks.&lt;/p&gt;

&lt;p&gt;However, I believe that understanding the basic idea of HTTP would be useful for many programmers, when thinking of what HTTP header should be added or thinking of what is HTTP/2 for example.&lt;/p&gt;

&lt;p&gt;In this post, I'm going to explain how HTTP works, starting with running TCP socket programs.&lt;/p&gt;

&lt;h1&gt;
  
  
  Tiny TCP socket programs
&lt;/h1&gt;

&lt;p&gt;Let's start with taking a look at TCP, which is underlying HTTP, with a tiny TCP socket program.&lt;/p&gt;

&lt;p&gt;The ability of TCP is quite simple, send / receive data as byte stream. There is no data format, no end of data, no rule for timing of sending data. Thus, client can send whatever data to the server at whenever it wants, and vice versa.&lt;/p&gt;

&lt;p&gt;Here is sample Ruby programs of TCP server / client, both of which can send data, input from keyboard, and output data, received from the other.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# server.rb&lt;/span&gt;

&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'socket'&lt;/span&gt;

&lt;span class="n"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;

&lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;TCPServer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;socket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;accept&lt;/span&gt;

&lt;span class="no"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="kp"&gt;loop&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;gets&lt;/span&gt;
    &lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt; 
&lt;span class="k"&gt;end&lt;/span&gt; 

&lt;span class="kp"&gt;loop&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;gets&lt;/span&gt;
  &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# client.rb&lt;/span&gt;

&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'socket'&lt;/span&gt;

&lt;span class="n"&gt;host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'127.0.0.1'&lt;/span&gt;
&lt;span class="n"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'20000'&lt;/span&gt;

&lt;span class="n"&gt;socket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;TCPSocket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 

&lt;span class="no"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="kp"&gt;loop&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;gets&lt;/span&gt;
    &lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="kp"&gt;loop&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;gets&lt;/span&gt;
  &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendmsg&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can check how they work by opening two terminals and running each scripts above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ruby server.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ruby client.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;* Note that &lt;code&gt;server.rb&lt;/code&gt; must be run first because &lt;code&gt;client.rb&lt;/code&gt; expects to the server already run.&lt;/p&gt;

&lt;p&gt;You can type any letters you want. When you type Enter key, you may notice that both client and server can send / receive data each other at any time. &lt;/p&gt;

&lt;h1&gt;
  
  
  Communication using HTTP
&lt;/h1&gt;

&lt;p&gt;Now, let's take a look at how HTTP clients send HTTP requests, using the previous &lt;code&gt;client.rb&lt;/code&gt; program.&lt;/p&gt;

&lt;p&gt;Before going ahead, we need a simple HTTP server as a sandbox.&lt;/p&gt;

&lt;p&gt;In theory, we can build HTTP server program by extending &lt;code&gt;server.rb&lt;/code&gt; program above, but it's too challenging to do within this post.&lt;/p&gt;

&lt;p&gt;Instead of building HTTP server program by ourselves, &lt;code&gt;WEBrick::HTTPServer&lt;/code&gt; in Ruby is available as HTTP server in localhost. Just copy &amp;amp; paste the CLI command below, and run it to start a HTTP server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ruby &lt;span class="nt"&gt;-rwebrick&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'WEBrick::HTTPServer.new(:DocumentRoot =&amp;gt; "./", :Port =&amp;gt; 20000).start'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal of this section is to send HTTP requests to the sandbox server above and receive 200 response with nice response body by sending appropriate data with &lt;code&gt;client.rb&lt;/code&gt; program.&lt;/p&gt;

&lt;h2&gt;
  
  
  Format of HTTP request
&lt;/h2&gt;

&lt;p&gt;As we saw in the previous section, communication between client and server with TCP socket does not have any rule about sending / receiving data.&lt;/p&gt;

&lt;p&gt;HTTP, which is based on TCP, is one of the protocols which provides the specification of "How server and client communicate each other". In other words, HTTP defines the data format, timing to send data, when to close connection, etc. &lt;/p&gt;

&lt;p&gt;You can check specifications in detail on &lt;a href="https://tools.ietf.org/html/rfc7230"&gt;RFC 7230&lt;/a&gt;. (I am also trying to read this page to write this post) &lt;/p&gt;

&lt;p&gt;Let's start with the first line of request. As defined &lt;a href="https://tools.ietf.org/html/rfc7230#section-3.1.1"&gt;section-3.1.1:RFC 7230&lt;/a&gt;, HTTP method, request target and HTTP protocol version appear on the first line, with the format below.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;method SP request-target SP HTTP-version CRLF&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If we want to send &lt;code&gt;GET&lt;/code&gt; request to the root path with &lt;code&gt;HTTP/1.1&lt;/code&gt;, for example, the first line should be like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET / HTTP/1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So let's try to send the data above using &lt;code&gt;client.rb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;client.rb&lt;/code&gt; and type the strings above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ruby client.rb
GET / HTTP/1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, press enter key &lt;strong&gt;twice&lt;/strong&gt; and you would get HTTP response with response code 200.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"HTTP/1.1 200 OK \r\n"
"Content-Type: text/ html; charset=\"UTF-8\"\r\n"
"Server: WEBrick/1.3.1 (Ruby/2.4.1/2017-03-22)\r\n"
"Date: Tue, 23 Jan 2018 13:33:51 GMT\r\n"
"Content-Length: 9173\r\n"
"Connection: Keep-Alive\r\n"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cool! We could send HTTP request to the server successfully with simple, tiny, toy TCP socket program.&lt;/p&gt;

&lt;h2&gt;
  
  
  Receiving HTTP Response
&lt;/h2&gt;

&lt;p&gt;Now, take a closer look at when the server sends response to the client.&lt;/p&gt;

&lt;p&gt;Remember that you pressed enter key &lt;strong&gt;twice&lt;/strong&gt; when you send a HTTP request, even though the first line ("GET / HTTP/1.1") had been sent right after the enter key was pressed once.&lt;/p&gt;

&lt;p&gt;It is because the server is supposed to return response after the client finishes sending all the data. Therefore, the server has to evaluate that it has received entire data by looking at the data itself according to specification of HTTP protocol.&lt;/p&gt;

&lt;p&gt;The entire HTTP request format is defined like this. (See &lt;a href="https://tools.ietf.org/html/rfc7230#section-3"&gt;section-3:RFC 7230&lt;/a&gt;)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;HTTP-message   = start-line&lt;br&gt;
                 *( header-field CRLF )&lt;br&gt;
                 CRLF&lt;br&gt;
                 [ message-body ]&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You may notice that &lt;code&gt;header-field&lt;/code&gt; is supposed to follow the first line, so the server cannot response before making it clear &lt;code&gt;header-field&lt;/code&gt; is over. In other words, the server calculates the end of &lt;code&gt;header-field&lt;/code&gt; with receiving double &lt;code&gt;CRLF&lt;/code&gt;. (see &lt;code&gt;CRLF&lt;/code&gt; appears at the end of &lt;code&gt;header-field&lt;/code&gt; first and again in the next empty line)&lt;/p&gt;

&lt;p&gt;That is why the HTTP server sent response to the client after pressing enter key twice, which means &lt;code&gt;header-field&lt;/code&gt; is empty and the request message is over here.&lt;/p&gt;

&lt;p&gt;Apart from &lt;code&gt;Keep-Alive&lt;/code&gt; header introduced in HTTP/1.1, HTTP connection would be closed after sending response from server to client once. &lt;a href="https://tools.ietf.org/html/rfc7230#appendix-A.1.2"&gt;(appendix-A.1.2:RFC 7230)&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In HTTP/1.0, each connection is established by the client prior to the request and closed by the server after sending the response.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can try to send data again after receiving responce, and you may soon notice that the connection is already closed. (&lt;code&gt;socket.sendmsg&lt;/code&gt; returns &lt;code&gt;nil&lt;/code&gt; repeatedly)&lt;/p&gt;

&lt;p&gt;A HTTP connection is over here and you must start with connecting to the server again.&lt;/p&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;We experienced connecting to HTTP server with TCP socket program in this post. It is clear now that HTTP is based on TCP connection and introduces common rules of &lt;strong&gt;how to use TCP&lt;/strong&gt; for efficient communication between web applications and clients (Mobile app, CLI programms, etc).&lt;/p&gt;

&lt;p&gt;Please note that the information about HTTP protocol introduced in this post is &lt;strong&gt;only a couple of features&lt;/strong&gt; of HTTP protocol. To understand HTTP in practice, you need to know much more, such as roles of request headers, connection management (such in &lt;code&gt;Keep-Alive&lt;/code&gt; header), or other things stated in the RFC documents.&lt;/p&gt;

&lt;p&gt;Hope this post will help you understand the first step of how HTTP works.&lt;/p&gt;

</description>
      <category>http</category>
      <category>tcp</category>
      <category>ruby</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Problems you faced on developing globalized web services</title>
      <dc:creator>Tsuyoshi Chujo</dc:creator>
      <pubDate>Wed, 24 Jan 2018 00:51:02 +0000</pubDate>
      <link>https://dev.to/chooyan/problems-you-faced-on-developing-globalized-web-services-1iad</link>
      <guid>https://dev.to/chooyan/problems-you-faced-on-developing-globalized-web-services-1iad</guid>
      <description>&lt;p&gt;Hi, &lt;/p&gt;

&lt;p&gt;I'm now researching how to globalize web services suitably, and I want to find out as many possible problems on globalizing web services as possible.&lt;/p&gt;

&lt;p&gt;Have you faced any problems (not only technical but also cultural, religious, linguistic, etc.) when you are developing web services targeting global audiences? If so, how did you solve them? &lt;/p&gt;

</description>
      <category>discuss</category>
      <category>globalization</category>
      <category>i18n</category>
    </item>
  </channel>
</rss>
