技術情報

Builder Design Pattern

Builder is a creational design pattern that allows you to build complex objects step by step. The pattern allows you to produce different types and representations of an object using the same building code.

The Builder pattern suggests that you extract the building code from the object of its own class and move it to separate objects called constructors.

To create an object, run a series of these steps on a constructor object. The important part is that you don’t need to call all the steps. You can call only the steps necessary to produce a particular configuration of an object.

Check out the sample codes below.

PHP sample code

C# sample code

By Yuuma



[Laravel] Passportを使用したBearer token認証[2]

PHPのLaravelフレームワークのPassportを使用したBearer token認証の方法について紹介いたします。本記事は前回の「[Laravel] Passportを使用したBearer token認証[1]」の続きとなります。今回はPassportのインストール方法からLaravel標準の認証機能をPassportに変更するところまでを説明します。

続きを読む

Laravel Livewire

I am talking about the brief introduction about laravel livewire today.

Its aim is to provide a modern and dynamic web experience without having to waste time with reactive web frameworks or Javascript at all.
And for the most part: it can. Livewire really works, and in the next few years we will almost definitely see some big, serious projects on it.

When you activate the livewire, you will

– Write a PHP class, which will act as the backend part of a frontend component. Public fields will be visible to Livewire.

– Write an interface component in the Laravel (Blade) template language. This component refers to the fields in the backend component that you wrote earlier.

– Write methods in your backend component class that change the state of public fields.

– Create an instance of the component in another view or another component.

– When you visit the page, Livewire will render the initial state of the component as HTML and inject it into the page you see. Livewire will have already attached auto-generated JavaScript events to the page, which call the methods you wrote in step 3 above.

– When you take action, the Javascript events that Livewire generates will make an AJAX request to the Livewire endpoint on the backend. This will call the method you wrote, changing the public properties you defined.

-Your backend component’s render method is then called, which produces a snippet of HTML. This HTML snippet is the response to the AJAX request.

– Finally, the client-side Livewire component hot-patches this HTML on the page.

Further more you can look up the livewire lifecycle hooks more details here.

https://laravel-livewire.com/docs/2.x/lifecycle-hooks

Livewire has lots of interesting features but it still have some drawbacks as follow.

– Livewire violates the separation of concerns

– Livewire violates the single-responsibility principle

– Livewire complicates the development workflow

– Too Many AJAX Requests

– Livewire is difficult to test

And Finally maintainability would be harder as the application grows.



InnoDB vs MyISAM

I talked about what is the MySQL storage engine last week. Today I will talk about the main difference between InnoDB and MyISAM.

The main difference between MyISAM and InnoDB are :

MyISAM does not support transactions by tables while InnoDB supports.

There are no possibility of row-level locking, relational integrity in MyISAM but with InnoDB this is possible. MyISAM has table-level locking.

InnoDB does not support FULLTEXT index while MyISAM supports.

Performance speed of MyISAM table is much higher as compared with tables in InnoDB.

InnoDB is better option while you are dealing with larger database because it supports transactions, volume while MyISAM is suitable for small project.

As InnoDB supports row-level locking which means inserting and updating is much faster as compared with MyISAM.

InnoDB supports ACID (Atomicity, Consistency, Isolation and Durability) property while MyISAM does not support.

In InnoDB table,AUTO_INCREMENT field is a part of index.

Once table in InnoDB is deleted then it can not re-establish.

InnoDB does not save data as table level so while implementation of select count(*) from table will again scan the whole table to calculate the number of rows while MyISAM save data as table level so you can easily read out the saved row number.

MyISAM does not support FOREIGN-KEY referential-integrity constraints while InnoDB supports.

By Yuuma



MySQL Storage Engines

Lets talk about the MySQL storage engines today.

A storage engine is a software module that uses a database management system to create, read, and update data in a database. There are two types of storage engines in MySQL: transactional and non-transactional.

For MySQL 5.5 and later, the default storage engine is InnoDB. The default storage engine for MySQL prior to version 5.5 was MyISAM. Choosing the right storage engine is an important strategic decision that will affect future development. In this tutorial, we will use MyISAM, InnoDB, Memory, and CSV storage engines. If you are new to MySQL and are studying the MySQL database management system, then this is not a big concern. If you are planning a production database, things get more complicated.

MySQL supported storage engines:

  • InnoDB
  • MyISAM
  • Memory
  • CSV
  • Merge
  • Archive
  • etc.

Today I will talk about the two main engines of MySQL. InnoDB & MyISAM.

InnoDB

InnoDB tables are fully transaction and ACID compliant. They are also optimal for performance. The InnoDB table supports foreign key, commit, rollback, and forward operations. The size of an InnoDB table can be up to 64TB.

Like MyISAM, InnoDB tables are portable between different platforms and operating systems. MySQL also checks and repairs InnoDB tables, if necessary, at startup.

MyISAM

MyISAM extends the old ISAM storage engine. MyISAM tables are optimized for compression and speed. MyISAM tables are also portable across platforms and operating systems.

The size of the MyISAM table can be up to 256TB, which is huge. Also, MyISAM tables can be compressed into read-only tables to save space. At startup, MySQL checks MyISAM tables for corruption and even repairs them in case of errors. MyISAM tables are not transaction safe.

Before MySQL version 5.5, MyISAM was the default storage engine when you create a table without specifying the storage engine explicitly. Since version 5.5, MySQL uses InnoDB as the default storage engine.

By Yuuma




アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム