<?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: Dmitry Kabanov</title>
    <description>The latest articles on DEV Community by Dmitry Kabanov (@dmitry-kabanov).</description>
    <link>https://dev.to/dmitry-kabanov</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%2F1144904%2Ffa684041-f19c-456a-bed4-cd5eaa64352b.jpg</url>
      <title>DEV Community: Dmitry Kabanov</title>
      <link>https://dev.to/dmitry-kabanov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dmitry-kabanov"/>
    <language>en</language>
    <item>
      <title>Model-View-Controller (MVC): origins of design pattern</title>
      <dc:creator>Dmitry Kabanov</dc:creator>
      <pubDate>Sun, 06 Oct 2024 14:07:34 +0000</pubDate>
      <link>https://dev.to/dmitry-kabanov/model-view-controller-mvc-origins-of-design-pattern-1677</link>
      <guid>https://dev.to/dmitry-kabanov/model-view-controller-mvc-origins-of-design-pattern-1677</guid>
      <description>&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" rel="noopener noreferrer"&gt;Model-View-Controller (MVC)&lt;/a&gt;&lt;br&gt;
is one of the most common design patterns used to develop&lt;br&gt;
applications with graphical user interfaces (GUI),&lt;br&gt;
especially in object-oriented programming languages.&lt;/p&gt;

&lt;p&gt;I summarize here three initial works on MVC from 1970s and 1980s&lt;br&gt;
along with my comments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;It is actually a meta design pattern that specifies splitting of software&lt;br&gt;
components in classes with distinct responsibilities.&lt;br&gt;
&lt;em&gt;Models&lt;/em&gt; are responsible for reflecting the application domain including&lt;br&gt;
the data that the application operates on.&lt;br&gt;
&lt;em&gt;Views&lt;/em&gt; are responsible for presenting the models to the user.&lt;br&gt;
&lt;em&gt;Controllers&lt;/em&gt; are intermediate components that process user actions&lt;br&gt;
and request models to read/modify the data in response to these actions.&lt;/p&gt;

&lt;p&gt;This idea was formulated in late 1970s in Xerox Palo Alto Research Center,&lt;br&gt;
and passed through multiple transformations,&lt;br&gt;
as the way GUI applications are written nowadays is not exactly the same&lt;br&gt;
as it was then.&lt;/p&gt;

&lt;p&gt;Particularly, modern applications are based on GUI toolkits that provide&lt;br&gt;
common widgets such as text fields and buttons, and processing user actions&lt;br&gt;
does not require an application programmer to implement code to determine&lt;br&gt;
which widget the user has clicked on,&lt;br&gt;
although it seems this was an important responsibility for controllers&lt;br&gt;
in the original idea, as will be seen below.&lt;br&gt;
Hence, the meaning of Controller has fluctuated, as&lt;br&gt;
many authors use the same word in different meaning&lt;br&gt;
(for example, in the &lt;a href="https://en.wikipedia.org/wiki/GRASP_(object-oriented_design)" rel="noopener noreferrer"&gt;GRASP patterns by Craig Larman&lt;/a&gt;),&lt;br&gt;
Controller object is non-UI class that handles external input, which,&lt;br&gt;
as we will see below, is not exactly how Controllers were thought of&lt;br&gt;
when the idea of MVC was created).&lt;/p&gt;

&lt;p&gt;There are multiple variations on the idea of MVC, such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://doc.qt.io/qt-6/model-view-programming.html" rel="noopener noreferrer"&gt;Model/View architecture in Qt&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.hackingwithswift.com/books/ios-swiftui/introducing-mvvm-into-your-swiftui-project" rel="noopener noreferrer"&gt;Model-View-ViewModel architecture in SwiftUI framework&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  MVC web frameworks like &lt;a href="https://www.djangoproject.com/" rel="noopener noreferrer"&gt;Django&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nevertheless, the main idea of MVC,&lt;br&gt;
the idea of &lt;a href="https://martinfowler.com/eaaDev/SeparatedPresentation.html" rel="noopener noreferrer"&gt;Separated Presentation&lt;/a&gt;,&lt;br&gt;
is preserved in all variations.&lt;/p&gt;

&lt;p&gt;One of the goals of reading initial works on MVC for me&lt;br&gt;
was to see how the MVC was defined initially and why there are so many&lt;br&gt;
variations of this pattern.&lt;/p&gt;

&lt;p&gt;To make it easier to understand MVC,&lt;br&gt;
it is useful to understand these design patterns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://refactoring.guru/design-patterns/observer" rel="noopener noreferrer"&gt;Observer pattern&lt;/a&gt; that allows one object (Observable) to inform
indefinite number of other objects (Observers) about some event;&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://refactoring.guru/design-patterns/composite" rel="noopener noreferrer"&gt;Composite pattern&lt;/a&gt; that allows to work with hierarchical projects
as with single entities;&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://refactoring.guru/design-patterns/strategy" rel="noopener noreferrer"&gt;Strategy pattern&lt;/a&gt; that allows one object (Context) to delegate an operation
to another object (Strategy).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Original MVC idea from PARC by Trygve Reenskaug
&lt;/h2&gt;

&lt;p&gt;The original version of MVC was developed by Trygve Reenskaug in 1979.&lt;br&gt;
The following original documents can be read at&lt;br&gt;
&lt;a href="https://folk.universitetetioslo.no/trygver/" rel="noopener noreferrer"&gt;his webpage at the University of Oslo&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://folk.universitetetioslo.no/trygver/1979/mvc-1/1979-05-MVC.pdf" rel="noopener noreferrer"&gt;Thing-Model-View-Editor, 12 May 1979&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://folk.universitetetioslo.no/trygver/1979/mvc-2/1979-12-MVC.pdf" rel="noopener noreferrer"&gt;Models-Views-Controllers, 10 December 1979&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  "Thing-Model-View-Editor", 12 May 1979
&lt;/h3&gt;

&lt;p&gt;This technical note seems to be the first&lt;br&gt;
prototype for the MVC architecture, although there are four, not three,&lt;br&gt;
objects (the author calls them metaphors) in this note.&lt;/p&gt;

&lt;p&gt;He provides examples of these objects from a software&lt;br&gt;
for planning system for large projects,&lt;br&gt;
that is, the projects, where one must do task management not&lt;br&gt;
in the head due to the number of different tasks and participants.&lt;/p&gt;

&lt;p&gt;The first object in this "quadriad" is &lt;em&gt;Thing&lt;/em&gt;, which is actually&lt;br&gt;
not something that belongs directly to software but something&lt;br&gt;
from the real world that is of interest to the user,&lt;br&gt;
something that the software is developed for.&lt;br&gt;
In the planning system,&lt;br&gt;
the examples of Things are &lt;code&gt;Gannt diagrams&lt;/code&gt; and &lt;code&gt;activities&lt;/code&gt;,&lt;br&gt;
that is, tasks with their &lt;code&gt;predecessors&lt;/code&gt; (previous tasks)&lt;br&gt;
and &lt;code&gt;successors&lt;/code&gt; (the following tasks).&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Model&lt;/em&gt; in this note is more or less the Model in MVC.&lt;br&gt;
It is a representation of Things in the form of data in computer,&lt;br&gt;
along with operations on these data.&lt;br&gt;
Using the large-planning-system example, activities&lt;br&gt;
are represented in the software as objects, where the collection&lt;br&gt;
of activities is a field in the class &lt;code&gt;NetworkModel&lt;/code&gt;, with the collection&lt;br&gt;
being represented as a dictionary.&lt;br&gt;
That is, the Model actually models&lt;br&gt;
the objects of the real world (even if they are abstract) in terms&lt;br&gt;
of data structures and object-oriented classes.&lt;br&gt;
The author also states the fundamental postulate of MVC here:&lt;br&gt;
&lt;em&gt;the Model is not concerned with the visual representation&lt;br&gt;
of the data on computer display&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;View&lt;/em&gt; in this note visually represents the Model,&lt;br&gt;
and there can be several Views attached to the given Model.&lt;br&gt;
The first two examples are lists of networks and the list of activities&lt;br&gt;
in a given network.&lt;br&gt;
The author models these lists as classes&lt;br&gt;
&lt;code&gt;NetworkList&lt;/code&gt; and &lt;code&gt;ActivityList&lt;/code&gt;, which are subclasses of &lt;code&gt;ListView&lt;/code&gt;.&lt;br&gt;
[ &lt;em&gt;I actually do not think that this idea of subclassing widgets&lt;br&gt;
(that is, generic GUI components like &lt;code&gt;ListView&lt;/code&gt;) has survived,&lt;br&gt;
as nowadays one would use just a generic &lt;code&gt;List&lt;/code&gt; widget parameterized&lt;br&gt;
by the actual list that it displays, without introducing subclasses.&lt;/em&gt; ]&lt;/p&gt;

&lt;p&gt;When the author explains how &lt;code&gt;ListView&lt;/code&gt; is organized, it gives us&lt;br&gt;
also the hint that the Editor (a.k.a. Controller) is basically&lt;br&gt;
attached to a given widget, while he gives examples that the Editor&lt;br&gt;
is responsible for organization of scrolling inside the view&lt;br&gt;
and reacting to the selected item in the ListView, e.g., by informing&lt;br&gt;
other views that an item is selected.&lt;br&gt;
Interestingly, the last statement is formulated as "The Editor&lt;br&gt;
then asks the &lt;code&gt;ListView&lt;/code&gt; and any other Views to select that item",&lt;br&gt;
which shows that apparently the Observer pattern was not the initial&lt;br&gt;
part of MVC but appeared later.&lt;br&gt;
What I mean is that the Editor was responsible to inform one or more&lt;br&gt;
Views about changes directly, not the Model, indirectly, via sending&lt;br&gt;
notifications to observers.&lt;br&gt;
I think this idea is used nowadays in the variant of MVC called&lt;br&gt;
&lt;a href="https://martinfowler.com/eaaDev/PassiveScreen.html" rel="noopener noreferrer"&gt;Passive View by Martin Fowler&lt;/a&gt;:&lt;br&gt;
one of the reasons for that is that it improves&lt;br&gt;
testability as the more active Controller can be tested&lt;br&gt;
with the mock of its View so that tests are independent of GUI framework.&lt;/p&gt;

&lt;p&gt;Additional quote I would like particularly&lt;br&gt;
put here as the hint that the views must be relatively passive&lt;br&gt;
in terms of the software functions&lt;br&gt;
as they are already reponsible for displaying:&lt;br&gt;
"This separation of user interface and actual command execution&lt;br&gt;
provides for great flexibility in the Editor."&lt;/p&gt;

&lt;p&gt;Then he gives an example of &lt;code&gt;ActivityText&lt;/code&gt; view which is a subclass&lt;br&gt;
of &lt;code&gt;TextView&lt;/code&gt;, generic component that is able to display textual&lt;br&gt;
information.&lt;/p&gt;

&lt;p&gt;The next two examples are representation of activities inside a given&lt;br&gt;
network in the subclass of the &lt;code&gt;DiagramView&lt;/code&gt;, which allows to visualize&lt;br&gt;
activities as rectangles with connections to their predecessors&lt;br&gt;
and successors.&lt;br&gt;
Here there are two views - one shows smaller networks with activities&lt;br&gt;
names and the other shows larger networks without activities names&lt;br&gt;
and on the gridded background.&lt;br&gt;
Here he mentions that not every aspect of the View can be deduced&lt;br&gt;
from the Model itself as the Model does not have any information&lt;br&gt;
about where to put on the screen a particular activity in the network.&lt;/p&gt;

&lt;p&gt;Here the author proposes again to model them as subclasses of the common&lt;br&gt;
view or as one view as a subclass of another.&lt;br&gt;
However, he also proposes here to have just one class &lt;code&gt;DiagramView&lt;/code&gt;&lt;br&gt;
that is parameterized by some field with values &lt;code&gt;small/large&lt;/code&gt;,&lt;br&gt;
so that an appropriate visualization could be chosen.&lt;/p&gt;

&lt;p&gt;The last two examples of views are &lt;code&gt;GanntDiagram&lt;/code&gt;&lt;br&gt;
(subclass of &lt;code&gt;ChartDiagram&lt;/code&gt;)&lt;br&gt;
and &lt;code&gt;ResourceDiagram&lt;/code&gt; (subclass of &lt;code&gt;DiagramView&lt;/code&gt;).&lt;br&gt;
Here the most interesting statements are that these view should provide&lt;br&gt;
operations that allow the user to retrieve some information&lt;br&gt;
by, say, pointing at some activity in the &lt;code&gt;GanntDiagram&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The last metaphor in this note, &lt;em&gt;Editor&lt;/em&gt;, is "an interface between a user&lt;br&gt;
and one or more views."&lt;br&gt;
Editor is responsible for providing commands to the user&lt;br&gt;
in the form of menus and coordinating views.&lt;/p&gt;

&lt;p&gt;The most interesting example of Editor given by the author&lt;br&gt;
is the Demonstration Editor.&lt;br&gt;
This Editor shows several panes in a single window, so that these panes&lt;br&gt;
reflect the modelled Activities network.&lt;br&gt;
Here the author states the following:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Each of its panes is a sub-Editor that communicates with its&lt;br&gt;
particular View.&lt;br&gt;
It also gives commands to the demonstration Editor and receives commands&lt;br&gt;
from it."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;which is basically the idea behind the much later developed patterns&lt;br&gt;
&lt;a href="https://www.lri.fr/~mbl/ENS/FONDIHM/2013/papers/Coutaz-Interact87.pdf" rel="noopener noreferrer"&gt;Presentation-Action-Control (1987)&lt;/a&gt;&lt;br&gt;
and &lt;a href="https://www.infoworld.com/article/2162000/hmvc-the-layered-pattern-for-developing-strong-client-tiers.html" rel="noopener noreferrer"&gt;Hierarchical MVC (2001)&lt;/a&gt;.&lt;br&gt;
Hence, the MVC from the very start was considered as a Model&lt;br&gt;
with a collection of Views and Editors (Controllers) that are connected&lt;br&gt;
to different aspects of the Model, with the Editors potentially&lt;br&gt;
being organized hierarchically.&lt;/p&gt;

&lt;h3&gt;
  
  
  Second technical note, 10 December 1979
&lt;/h3&gt;

&lt;p&gt;The second note is actually very short (two pages) but has extremely&lt;br&gt;
important statements about the role of each component in MVC.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  "Models represent knowledge", that is, they represent the domain
in which software operates. The author also notes that usually there are
multiple models if the application domain is nontrivial.&lt;/li&gt;
&lt;li&gt;  Views represent models visually. The author states also that the
views are coupled to models (or submodels) as they can directly request
data from models and can send messages to models to update themselves.&lt;/li&gt;
&lt;li&gt;  "A controller is the link between a user and the system.
It provides the user with input by arranging for relevant views
to present themselves in appropriate places on the screen."
The author also states that
"Conversely, a view should never know about user input,
such as mouse operations and keystrokes.
It should always be possible to write a method in a controller
that sends messages to views which exactly reproduces any sequence
of user commands."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I find this short technical note very insightful.&lt;br&gt;
I have understood the idea of a Model long time ago:&lt;br&gt;
it is in general a whole network of collaborating objects,&lt;br&gt;
representing application domain.&lt;br&gt;
Also, the statement that Controller is responsbile&lt;br&gt;
for arranging for relevant views&lt;br&gt;
is very interesting as this is not obvious to understand,&lt;br&gt;
for example by reading about MVC in Wikipedia.&lt;/p&gt;

&lt;p&gt;The idea of views not knowing about keystrokes and mouse operations,&lt;br&gt;
I think, did not survive.&lt;br&gt;
I think with modern toolkits the views are actually responsible&lt;br&gt;
for knowing about these things,&lt;br&gt;
while Controllers are actually not concerned with these things anymore.&lt;br&gt;
However, I think Controllers are in general written in such way&lt;br&gt;
that tests should be possible without GUI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Paper by Krasner &amp;amp; Pope from 1988
&lt;/h2&gt;

&lt;p&gt;G.E. Krasner and S.T. Pope published the &lt;a href="https://dl.acm.org/doi/10.5555/50757.50759" rel="noopener noreferrer"&gt;paper&lt;/a&gt;&lt;br&gt;
"A cookbook for using the model-view controller user interface paradigm&lt;br&gt;
in Smalltalk-80" in the Journal of Object-Oriented Programming&lt;br&gt;
in 1988 that was, AFAIK,&lt;br&gt;
the first published work about MVC not from the authors.&lt;/p&gt;

&lt;p&gt;One of the most interesting aspects of this paper for me was that&lt;br&gt;
the authors basically mention several design patterns several years before&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Design_Patterns" rel="noopener noreferrer"&gt;the book by Gang of Four&lt;/a&gt;&lt;br&gt;
that made the idea of design patterns popular.&lt;/p&gt;

&lt;p&gt;The authors mention in the beginning:&lt;br&gt;
"The use of pop-up versus fixed menus, the meaning attached to&lt;br&gt;
keyboard and mouse/function keys, and scheduling of multiple&lt;br&gt;
views should be choices that can be made independently of the&lt;br&gt;
model or its view(s)", which further augments the idea that the Controller&lt;br&gt;
component is responsible for orchestrating the views,&lt;br&gt;
found in the &lt;code&gt;Demonstration Editor&lt;/code&gt; example from the first technical&lt;br&gt;
note by Trygve Reenskaug.&lt;/p&gt;

&lt;p&gt;"Each view may be thought of as being closely associated with a controller,&lt;br&gt;
each having exactly one model.&lt;br&gt;
But a model may have many view/controller pairs".&lt;br&gt;
This is a very important idea, that they will further use in this paper&lt;br&gt;
by introducing the Observer design pattern to MVC.&lt;/p&gt;

&lt;p&gt;The authors state that the Model can be as simple as an integer, for example,&lt;br&gt;
for a trivial app that counts how many times user has clicked on a button,&lt;br&gt;
or a complex object consisting of multiple objects.&lt;br&gt;
This is the same statement about Model as was in the original formulation.&lt;/p&gt;

&lt;p&gt;Additionally, the authors explictly state that the Views obey to the&lt;br&gt;
Composite design pattern, that is, that the views can have subviews&lt;br&gt;
and be put into superviews.&lt;br&gt;
Therefore, a message &lt;code&gt;display&lt;/code&gt; (on a Model update)&lt;br&gt;
is passed from top-level views to its subviews transparently.&lt;/p&gt;

&lt;p&gt;"Controllers also deal with scheduling interactions with other&lt;br&gt;
view-controller pairs: they track mouse movement between application views&lt;br&gt;
and implement messages for mouse button activity&lt;br&gt;
and input from the input sensor."&lt;br&gt;
They also say that the menus are in the realm of Controllers.&lt;/p&gt;

&lt;p&gt;The interaction between these three components is as follows.&lt;br&gt;
The Model does not know anything about controllers and views.&lt;br&gt;
The Controller requests updates on the Model in response to user actions.&lt;br&gt;
The Model carries out the requested operations.&lt;br&gt;
As they can be multiple views connecting to the same Model, they all&lt;br&gt;
must be updated when the Model is updated to preserve consistency.&lt;br&gt;
This is where the Observer design pattern appears (it is called &lt;em&gt;Dependents&lt;/em&gt;&lt;br&gt;
in the paper): Controllers and Views connected to the Model register&lt;br&gt;
as its dependents, and the Model informs them about the changes, which&lt;br&gt;
can be parameterized, so that different types of changes are passed only&lt;br&gt;
to the dependents that are interested in them.&lt;/p&gt;

&lt;p&gt;When all the interested dependents are informed about the changes,&lt;br&gt;
they can update themselves.&lt;br&gt;
Views ask the Model about the updated state. Controllers may also update&lt;br&gt;
themselves in reaction to the Model changes, for example, some menu items&lt;br&gt;
can be enabled/disabled due to the new Model state (e.g., when a text&lt;br&gt;
document is changed after it was saved, the Controller can enable "Save"&lt;br&gt;
button in the toolbar).&lt;br&gt;
In principle, the View that represents these toolbar&lt;br&gt;
can enable this button---this is one of the situations where distinction&lt;br&gt;
between Controller and View is blurry.&lt;br&gt;
The way of thinking about why the Controller must do it, not the View,&lt;br&gt;
is that the View visualizes the Model itself,&lt;br&gt;
while the Controller is responsible for graphical parts&lt;br&gt;
of the application interface).&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;So after reading these three original works, from 1979 and 1987,&lt;br&gt;
I can say the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  the original idea of Model as a representation of application domain
was there from the very beginning;&lt;/li&gt;
&lt;li&gt;  the idea of hierarchy between Controllers was also there from the very
beginning, as a way to manage complex views consisting of subviews;&lt;/li&gt;
&lt;li&gt;  the idea of Model being completely oblivious to Controllers and Views
is one of the ideas that is preserved in all variations on the MVC idea;&lt;/li&gt;
&lt;li&gt;  the idea that Controllers know about mouse/key events, I think,
in general, did not survive, as now GUI toolkits, which Views are based on,
handle these things themselves, and Controllers' main responsibility
is to pass external requests to Model;&lt;/li&gt;
&lt;li&gt;  both original works by Trygve Reenskaug as well as the paper
by Krasner &amp;amp; Pope state that quite often not everything about application
behavior can be derived from Model: a lot of aspects, such as disabling
menu items or buttons, how to display data, and so on, lead to the idea
of Presentation Model (or ViewModel) which is responsible for tackling
these aspects, which are more application-centric, than domain-centric;&lt;/li&gt;
&lt;li&gt;  the paper of Krasner &amp;amp; Pope introduced the Observer design pattern
to MVC with the goal of decoupling Model from Controllers and Views
and to simplify handling updates of multiple Views attached to the same
Model;&lt;/li&gt;
&lt;li&gt;  the paper of Krasner &amp;amp; Pope introduced also the Composite design pattern
for structuring Views, although to some extent the Demonstration Editor
example from the original technical report by Trygve Reenskaug
introduced the same idea, although not explicit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

&lt;p&gt;This post was originally published on my personal website: &lt;a href="https://dmitrykabanov.com/blog/2024/mvc-part-1/" rel="noopener noreferrer"&gt;https://dmitrykabanov.com/blog/2024/mvc-part-1/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>designpatterns</category>
      <category>mvc</category>
    </item>
    <item>
      <title>How to mirror GitLab repo to GitHub</title>
      <dc:creator>Dmitry Kabanov</dc:creator>
      <pubDate>Wed, 23 Aug 2023 21:56:01 +0000</pubDate>
      <link>https://dev.to/dmitry-kabanov/how-to-mirror-gitlab-repo-to-github-5835</link>
      <guid>https://dev.to/dmitry-kabanov/how-to-mirror-gitlab-repo-to-github-5835</guid>
      <description>&lt;p&gt;If you have a &lt;a href="https://gitlab.com" rel="noopener noreferrer"&gt;GitLab&lt;/a&gt; repo and would like to mirror it in your &lt;a href="https://github.com" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; account, it can be set up directly in the GitLab repo settings. Note that here we use new fine-grained tokens functionality of GitHub (which is currently in beta, as of May 2023).&lt;/p&gt;

&lt;p&gt;Go to the project's settings (Settings -&amp;gt; Repository) and expand "Mirror repository". You will see the following form:&lt;br&gt;
&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%2F36gr1b8ts4u8xsdnjfx3.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%2F36gr1b8ts4u8xsdnjfx3.png" alt="Mirror repository form on GitLab" width="800" height="569"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the "Git repository URL", you need to specify the HTTPS URL for the repo on GitHub in the following format:&lt;br&gt; &lt;code&gt;https://github-username@github.com/github-username/repo.git&lt;/code&gt; &lt;br&gt;
Note the added username part between &lt;code&gt;//&lt;/code&gt; and &lt;code&gt;@&lt;/code&gt; in the above URL --- when you create a repository on GitHub, the generated URLs do not have this, so you need to add it manually!&lt;/p&gt;

&lt;p&gt;Now, for a password, we use &lt;a href="https://github.com/settings/tokens?type=beta" rel="noopener noreferrer"&gt;fine-grained tokens&lt;/a&gt;. Press "Generate new token" button and choose read and write permissions for "Contents".&lt;/p&gt;

&lt;p&gt;Copy the generated token and paste it into the "Password" field in GitLab. Finally press "Mirror repository" button. Once you see a table with mirrors appeared, you can press "Update now" (two arrows) button to check if everything works correctly.&lt;/p&gt;

&lt;p&gt;Right now, usability is a bit off, as if something is not working, you have to delete the mirror and start over again. It would be a better user experience, if GitLab allowed to edit the mirror settings.&lt;/p&gt;

&lt;p&gt;Hopefully, these instructions work good for you. Enjoy!&lt;/p&gt;

&lt;p&gt;P.S. This two StackOverflow posts were really helpful to write the above instructions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/30268549/mirroring-from-gitlab-to-github" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/30268549/mirroring-from-gitlab-to-github&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/63906613/minimal-set-of-scopes-to-push-to-github-using-an-access-token" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/63906613/minimal-set-of-scopes-to-push-to-github-using-an-access-token&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gitlab</category>
      <category>github</category>
      <category>git</category>
    </item>
  </channel>
</rss>
