First 250 days of software dev - Part 11

13 min read

Day 101

I wanted to illustrate the distinction between composition and dependency, so I produced one: human, mountain, Earth. The Earth contains the man and the mountain. There is a relationship of ownership and part-whole. The Earth does not depend on the mountain or the human being for its existence. So there is no "dependency" here for the world. There is "association" in the most general sense. We can give the moon as a distinctive example for association. The Earth can use the Moon satellite to maintain the tides in the ocean object it possesses. Here, "use" is emphasized rather than ownership. This is also an accosication. Man is a part of the earth, but man can exist outside the earth object (he can live on different planets and satellites when appropriate conditions are met). The mountain cannot exist outside the earth. There is such a difference between Earth-human and Earth-mountain, even though the Earth has both. The Earth-human relationship is an aggregation relationship whose superset is asscociation. The Earth-mountain relation is a composition relation whose superset is association. Since the example would be inefficient if we expanded these lines of thought, we can grasp the concept from this narrow framework.

Inheritance is simpler to understand: Man is not the Earth. It should not take on its characteristics (one should not think that we all came from the earth and will go to the earth). Man is a primate, an animal, a creature, a concrete being. All of them can inherit common human characteristics and procedures. The problem with inheritance is that it is like steel. It does not stretch easily, it is hard to shape by beating. That's why the GoF book says "prefer composition over inheritance". It doesn't mean make a composition relation everywhere you see it. Prefer composition because it is easier to change the behavior of the object using dependency injection/setter. In inheritance, it is not possible to derive objects from more than one type (at least in most software languages) and it is coupled. Therefore, the use of interfaces and abstract classes becomes important. If I go into SOLID principles, which are complementary to each other in this article, the topic will get longer. Inheritance is like steel, composition is like copper. It is easier to forge, process, shape and modify. In order to use Inheritance like copper, it is necessary to know SOLID principles and pay attention to these principles during the design phase of classes. In short, the polymorphism provided in the OCP, Liskov, ISP principles of SOLID is the most important issue in this flexibility.

These are the things I learned the best. I hope I didn't learn it wrong. I don't think it is yet possible to explain the whole structure in the best way with a single sentence.

I thought about what I did today. Thinking about the objects on the site, their relationships, their structures was what I did the most. Today I thought I would work on products and categories and make class diagrams. There were so many interconnected parts that sometimes I didn't know which one to focus on, and I thought I could look at some places while thinking about a different scenario and connect them with the objects used here. Did I think about Liskov for example in the places where there is Inheritance? No, I didn't. What I did was wrong, I realize that and I condemn myself, but I don't enjoy humiliation, so I keep the condemnation short and say to myself "you'll focus on that too".

Will I be productive after 2 months?" Although it is best to say "Only God knows", I think I can. I look at the path we have traveled in 4 months and I also look at different people's stories about the development processes of people at the beginning of this subject. In 4 months, even though I don't know exactly where I am, I know that I have done enough work and that you have helped me a lot. What has happened in 4 months. I remember that coding, project process, failing, succeeding, every time an alarm sounded in my dreams, "yes, I completed this part, now let me complete this part" software process management. At the end, I hope I will wear the gold bracelet on my hand.

Day 102

Today I continued on the same topics. Yesterday I tried to think about the product and category and tried to do something, but it was not completed. Today I added some missing parts and then looked at adding the product to the cart and purchasing. It's not complete yet. For the last 3 days, my brain has been so full that I feel like the stagnation of a "cold-blooded" insect that moves very slowly in the house during the winter months is what is happening in my brain. Still, somehow there is progress, of course. At least I am thinking about the system and getting to know it more closely.

Day 103

I spent the whole day on the payment system. At the beginning, I thought about the relationship with the payment methods. Then I read the parameters received from Iyzico and given to Iyzico from their site. I assumed that these parameters were also in Gpay, Paytr, Papara. Or at least I thought that they should be very similar. When designing the payment system, there were very interrelated structures. Interface-abstract class usage was mandatory. But I couldn't figure out where and how many relationships there were. Then I looked at what design patterns people had used before in payment. I generally encountered factory method, strategy and facade patterns. There were many similar examples of using simple factory and strategy pattern together, especially in both authentication and checkout. Afterwards, I spent most of the day again understanding these design patterns and theoretically designing how I could fit them into my own system. While looking at the strategy pattern, the open-closed principle directly caught my eye. It seemed like its whole purpose was to provide it. I didn't really find much difference with Factory. Although they mentioned a lot of differences in stack overflow, I haven't grasped it yet. The clearest thought I saw was that the payment methods should have a common structure and instead of using them all with a hardcoded structure, we should follow OCP and not update the old parts of the system when we add or delete a new payment method. I thought just a simple factory design pattern would be enough and I started to implement it. It's not finished yet. The reason I came to the last conclusion may be because I couldn't understand the difference between Factory-Strategy patterns. Although they are very similar in structure, I understand that the reasons for using them are different. I think the design patterns are topics that I can use and keep in mind as I encounter problems. I will solve that too.

Almost every new day I want to do so many things: understand the algorithms book completely to every point, iterate the examples myself, then code and create a perfect frontend and user interactive algorithm library, study artificial intelligence (what can be done in the web space differently) and create small projects of my own, learn javascript (plain-normal, node, even react). In general, I'm at peace because it's all something I love and I'm satisfied. Of course, these extreme examples are things that can be done later as a hobby rather than a job. But the fact that it can be done as a hobby is the best part of the job.

I still haven't done a good research and I haven't focused on inflation neutrality or a system where there is no volatility of currencies. But that's always in the back of my mind.

Day 104

When I said that I should use SOLID fully, I did it by creating different classes for each part that contains information about the user. I thought that I would pull the necessary parts from the User class and complete the operations in that way. I could do this by using DI, I thought wrong. Maybe I should have thought about the single responsibility in SOLID by looking at the system from a slightly larger scale. I'm upset with myself. I may have gassed myself like Fatih Terim uses the method of constant gassing while giving strategy to the team. I will learn to walk by falling. This week has been like a child learning to walk for the first time and trying to do something without parental support. I hope to stand on my own feet soon (in terms of software).

Day 105

Today, I went through the mix. For the first time, I saw how to work concretely on SEO, which I had read about before. More precisely, beyond SEO, today I learned what Google Analytics does, what user statistics are (demographics, interests, session times, activities (e.g. purchases), browser information used, country of access, user bounce rate, etc.), data about user traffic, the ways used to access the site (acquisition: paid search, for example), the ways in which the site was advertised and which type of ad was used to see which users came from these ads in analytics. I talked about event generation, which is a concept that works mostly in retargeting and remarketing, where user data can be analyzed in real time. I also saw the use of Criteo. I learned that it can be used instead of Google ads (for example, you can also advertise on firefox).

I understood the importance of a sitemap, what indexing does. I learned that the Soft 404 error and the use of the noindex tag are SEO's nightmare.

The main thing I learned today is that if I said I would say something, if I wrote it down, I should not forget it. I don't have that luxury. See here: French.

I found that the simplest way to report when there is an error somewhere is to specify the error and the location of the error as a title, then send the description and screenshot to the relevant person.

Afterwards, I did a lot of reading about SEO from Google's own documents. Before that, I looked at a little more class diagrams. Although there are plenty of shortcomings, I think that a part of the basic skeleton has been formed and I think that the structure will be on solid foundations while coding.

Day 106

Today I continued both the SEO part and our existing task. There is so much information about SEO that I am still trying to learn by digesting it. My main source is google developers documents. I have been looking at them at the end of work for two days. The most memorable of our work today was the work on the links given to the site and the links that exist on the site. For example, I saw the contribution of giving backlinks to the hardware news footer. For example, hardware news had this backlink and did not have a nofollow tag. If there is no nofollow tag, there is a possibility that the site reputation (reputation) may fall in the eyes of google. There are harmful aspects such as a link can go to a spammy lyre site, it can narrow our traffic volume. So why didn't Donanım Haber use the nofollow tag? It tells Google that this link is sponsored. Seeing that it is a sponsored link, Google says "aa ok then no problem". Similar to nofollow, there are also noreferar and noopener tags. In summary, I need to use them in the links on my site for SEO.

Today I also looked at Semrush, Ahrefs, Serp, etc. I got a bit familiar with them. I saw Semrush's suggestion ideas for pages and I was a bit fascinated by its algorithm. It was showing an error about pagination (they all showed the same page title and that was the problem). In the evening I did some research and found a few useful solutions: "Use Rel='next' and Rel='Prev' for Paginated Page Series", "Use the Canonical Tag Rel='Canonical'", "Remove Content from the Google Index", and more. But I don't know which one will be more effective yet.

While reading about SEO, I came across a couple of Google's suggestions for photos, different from the one I'm using now: For example, it said that presenting images with the <pictures> tag is more useful in terms of responsiveness. He also praised SVG format photos quite a lot compared to other raster graphic formats (jpg, png, etc.). As far as I understand, SVG format images are useful for reducing HTTP requests because they have less size. He also praised the Data URI, but I didn't investigate it too much when I saw that it has many disadvantages. In addition, for example, if you want to add an image with the <img srcset> tag, it may not be detected in every browser, and he recommended giving a backup url as "img src". This seems ridiculous to me. If not every browser supports it and the recommended way of using it doesn't have big advantages, why should I choose it? I think I shouldn't choose it.

Day 107

First of all, I realized that I need to make a database connection for the queries I will use after the database-related work and a general work for the queries.

My plan was this: First I was going to create a singleton class for database connection. But this connection should be flex so that it can be made not only to mysql but also to PostgreSQL. For this I created a structure inside the contructor in my singleton class. I tried to create a common structure with the option to connect to the mysql server with mysqli and pdo and a connection to the PostgreSQL server. I transferred the logic related to the connections to the classes to the common interface. Since the purpose of the database connection is to give and receive information, I created a Query class that contains the content and methods of this communication. In its final form <<$query = new Query($mysqli); $query->insert(["table" => "Directors", "keys" => ["Name", "Surname", "Age"], "values" => ["Stanley", "Kubrick", "66"]]]);>> will be able to make simple queries like this anywhere in the system. If I can manage it.

At this stage I'm so focused on writing that I haven't made any real database connections yet and I don't know how many bugs there are in the code. I believe that if I can get the logic right, I'll be able to fix those bugs tomorrow.

I'm trying to build a common structure for both mysqli and pdo. It may seem like a bit of unnecessary trouble. If it will take too much time on errors, one of them can be left for future development.

Today I had a hard time creating the prepared statement with mysqli connection and I will probably solve it difficult because I always had the biggest problem there when I was working with query builder.

Day 108

I had to complete the methods for the database query class today. Yesterday I had to finish the insert part and today I had to finish the rest of it and let me make enough queries in formats that I can use.

What has been done in two days and what is expected to be done tomorrow can be summarized as follows:
  1. Created a class where a singleton database connection will be created and I will obtain this connection.
  2. This class could call different classes according to the connection method when creating the connection (at first I thought of the connection as composition, but the second created class (for example MYSQLI class) was also used for Query class. Therefore, since there was only one class that used two different classes, the relationship was aggregation, i.e. pass by reference.
  3. The MYSQL or POSTGRESQL class must have a common face. It provides convenience to the client in future uses.
  4. Normally I would write CRUD methods for both mysqli and pdo, but since prepared statements take a bit too much time, only PDO is preferred in this example.
  5. Currently the queries are operating under limited conditions. These conditions are considered adequate for this project at this stage.
  6. The problem may be especially here: For example, in the "WithMySQL" class, both the connection database is created with mysql methods and crud operations are provided. There was a possibility to separate it into different classes. It would even be more elegant. It was written with this situation in mind.
  7. Tomorrow, we can probably utilize the frontend of an old project that we have designed before and exchanged data from the user, and user registration and login stages can be provided with this design. Or only the PHP part can be continued.

Day 109

The problem today was this: Some of the mistakes I cause I do without expecting a mistake, and some mistakes I create on purpose, or the system works correctly and the mistake comes. In some places I couldn't figure out whether I wanted the mistake or not. The biggest problem of the day was the fight against mistakes.

Made today: Database and query classes were used in registration related classes created to register the user, send activation link, activate the user according to the returned link and tag the activation code used as "used".

I have a question: what can be done to invalidate activation links that have not been used for a long time (for example by changing the code state)? I created an event in mysql and created the necessary sql query, but I saw that I don't have authorization for such an operation in the database. I haven't been able to fix this problem yet. Also, thinking that I can't send an email from locale (there is a way to do that, of course), I assumed that part was done. Obviously, the registration phase seems to be completed on the server side. Tomorrow I will complete the login part, then I will complete the prototyping of the registration and login (with frontend) and move on to the other stages.

Day 110

It was the most unproductive day in 110 days until lunch time. The stomach problem affected my focus badly. So I couldn't do much today. I solved the last fatal error in yesterday's work. Then, since the user can perform the recording process with facebook and twitch, I will add the parameters provided and received to the api as input/output with a function as an example. When I complete this part, the recording is finished.