YouTube2Text

πŸ”” Java / Full Stack Developer | 2–8 Years Experience | Spring Boot | Microservices | ReactJS | Git β€” Transcript

by Insights Instructor Β· 6,084 words Β· 882 segments Β· language en Β· Watch on YouTube

Full transcript

  1. 0:00Can you please tell me about yourself?
  2. 0:02>> Yeah. Hi. So, I am a software developer
  3. 0:05with around 3 years of experience. Uh
  4. 0:07mostly I have worked on the backend
  5. 0:10development and uh my core technical
  6. 0:13skills basically include uh Java, Spring
  7. 0:16Boot and microservices and I have
  8. 0:18hands-on experience in designing and
  9. 0:20developing REST APIs and working with
  10. 0:23databases and also integrating different
  11. 0:26services. And uh apart from that I also
  12. 0:29have some basic exposure to front- end
  13. 0:31technologies like react and all. So
  14. 0:33basically this helps me to understand
  15. 0:36like in application flow. So uh so I
  16. 0:39have worked in agile environment also
  17. 0:42and activate and actively participate in
  18. 0:44code reviews as well and apart from that
  19. 0:47I also do participate in the uh
  20. 0:49production issues resolution whenever
  21. 0:51the testers uh raises the bug and uh
  22. 0:54debugging the issues also. So yeah, so
  23. 0:57this is all about myself and uh my daily
  24. 0:59activities. Yeah.
  25. 1:00>> Okay. So can you tell me about your
  26. 1:02current project?
  27. 1:04>> Yeah, I am currently working on an
  28. 1:05e-commerce application uh that is built
  29. 1:08using the spring boot and microservices
  30. 1:10architecture. So the system consists of
  31. 1:11multiple services such as product,
  32. 1:13order, user and notification services.
  33. 1:16And uh in that my responsibilities
  34. 1:18include developing and maintaining
  35. 1:20backend APIs and implementing business
  36. 1:22logic and handling databases interaction
  37. 1:24and improving the performance and
  38. 1:26scalability. So the application
  39. 1:29basically supports the features like
  40. 1:31product search, order processing and not
  41. 1:33notifications and uh that is designed to
  42. 1:36handle the high traffic uh during the
  43. 1:38peak sales. So uh we use the scalable
  44. 1:41and usually coupled services in order to
  45. 1:43handle all this. So yeah so this is what
  46. 1:45is about my project in very brief.
  47. 1:47>> Okay. So can you explain how ReactJS is
  48. 1:51integrated with the back end and can you
  49. 1:54describe the complete end toend flow
  50. 1:57when a client makes any request?
  51. 2:00So can you tell me the whole flow?
  52. 2:02>> Uh yeah sure. So in our application,
  53. 2:05ReactJS is used for the uh front end and
  54. 2:09spring boot is used for the back end. So
  55. 2:12let me explain in toend flow using the
  56. 2:14like let's say simple example for the
  57. 2:17fetching the product details. So first
  58. 2:19user opens the application in the
  59. 2:21browser and uh react application is
  60. 2:24already loaded in the browser and it
  61. 2:27shows the UI. So when the user clicks on
  62. 2:29the button like uh view products so
  63. 2:32reactjs and API call using the tools
  64. 2:35like uh fetch or exio so the API request
  65. 2:39is sent from the browser to the backend
  66. 2:42rest api endpoint. So that is exposed by
  67. 2:44the spring boot basically. So for
  68. 2:46example we can have like something like
  69. 2:49uh forward/ a like localhost at80 and
  70. 2:52then forward/ uh api and products. So
  71. 2:56something like that. So it will
  72. 2:57basically try to get the request and the
  73. 3:00request goes through the security
  74. 3:02filters if authentication is enabled. So
  75. 3:04the spring boot controller receives the
  76. 3:06request and then it forwards it to the
  77. 3:09service layer. So there the business
  78. 3:10logic is handled. So whatever the
  79. 3:12business logic we have written based on
  80. 3:14that it will be further processed. So
  81. 3:16the service layer then calls the
  82. 3:17repository layer and it fetches the data
  83. 3:19from the database. So once the data is
  84. 3:21retrieved then the back end sends the
  85. 3:23response back to the react application
  86. 3:25in JSON format. So then react receives
  87. 3:28this response and it updates the uh like
  88. 3:31state and rerenders the UI to display
  89. 3:34the product list uh on the screen. So
  90. 3:36all this happens like without reloading
  91. 3:38of the page and giving better experience
  92. 3:40to the user. So this is what is like
  93. 3:43whole end to end flow how react and
  94. 3:46spring boot work together when like any
  95. 3:48client makes a request. So yeah.
  96. 3:51>> Okay. Can you tell me how does React
  97. 3:53handles the API errors which is coming
  98. 3:56from the back end?
  99. 3:57>> Yeah, React itself does not handle the
  100. 4:00API errors automatically basically. So
  101. 4:02we handle errors in the code when the uh
  102. 4:05like when we make an API call. So when
  103. 4:08reject call say backend API using the
  104. 4:11fetch or exio so we use try catch block
  105. 4:15or an error uh like block. So error call
  106. 4:19back will be there. So if the back end
  107. 4:21returns like error we may have like 400
  108. 4:25401 404 or maybe 500. So we can catch
  109. 4:29the error in react. So after catching
  110. 4:32the error like uh we show a proper error
  111. 4:35message to the user like uh maybe
  112. 4:37something went wrong or unauthorized
  113. 4:40access based on the access code what we
  114. 4:42receive. So based on that we can uh
  115. 4:45write some specific message and we can
  116. 4:48show the fallback UI like uh maybe error
  117. 4:51message or uh toast notification or
  118. 4:54alert also we can show and for the
  119. 4:57authentication errors like maybe 401 or
  120. 5:00403 we usually redirect the user to the
  121. 5:03login page. So uh we also stop loaders
  122. 5:06or spinners uh so the UI uh does not get
  123. 5:10stuck. Yeah. So in short like React
  124. 5:12handles the back end API errors by
  125. 5:13catching them from the API call itself
  126. 5:16and uh we saw the meaningful uh message
  127. 5:19or notification or alert uh as per the
  128. 5:22requirement. So yeah.
  129. 5:24>> Okay. So what will happen if the backend
  130. 5:26API is very slow or time out happens
  131. 5:30from the UI?
  132. 5:32>> Yeah. If the back end API is slow or
  133. 5:34timeout happens then the React
  134. 5:36application like keeps waiting for the
  135. 5:38response and during this time you we
  136. 5:40usually show a loading indicator or a
  137. 5:43spinner so the user like knows that
  138. 5:46something is happening and if the API
  139. 5:48takes too long time and it uh like um uh
  140. 5:52we will have the some time out will be
  141. 5:54there so the loading will appear for
  142. 5:56some specific time only and uh if
  143. 5:58timeout happens then react catches the
  144. 6:00error in the API call. So when uh
  145. 6:03timeout is uh or when the timeout
  146. 6:06happens or uh or slow response happens
  147. 6:09then we saw some user friendly messages
  148. 6:11like maybe uh like request is taking too
  149. 6:14long uh please try again or something uh
  150. 6:16like or maybe we retry the request
  151. 6:19automatically or allow the user to retry
  152. 6:21manually also. So it all depends on the
  153. 6:24again scenario best thing. So yeah.
  154. 6:26>> Okay. Do you know what is COR is and
  155. 6:30have you ever faced this issue?
  156. 6:33>> Yeah, CO is basically Yeah, that stands
  157. 6:36for the cross origin uh uh R for
  158. 6:39resource sharing. So that is cross
  159. 6:41origin resource sharing. So it is a
  160. 6:44browser security rule. So that basically
  161. 6:47controls whether a front-end application
  162. 6:50can call a backend API from different
  163. 6:52domain port or protocol. So yeah we have
  164. 6:56faced this issue. So it usually happens
  165. 6:58when the like react front end and spring
  166. 7:02boot back end are running on a different
  167. 7:04ports or domains. So for example uh
  168. 7:07whenever we are using react so some so
  169. 7:10it will be suppose it is up on the local
  170. 7:12host uh 3000 port and if uh we have a
  171. 7:16backend uh spring boot application so
  172. 7:18that might be running on the local host
  173. 7:20at80. So in this case the browser blocks
  174. 7:23the request for the security region and
  175. 7:25it shows the CS error. So to fix this we
  176. 7:28allow the front end uh origin in the uh
  177. 7:31back end by we use like add of cross
  178. 7:34origin annotation in the spring boot or
  179. 7:36we configure the course uh globally in
  180. 7:39the back end configuration. So once the
  181. 7:41back end allows the front end origin
  182. 7:43then the browser allows uh the request
  183. 7:46to go through. So yeah, so in the very
  184. 7:48like in the simple words we can say like
  185. 7:50cos is a browser uh restriction and we
  186. 7:53fix it by properly configuring the back
  187. 7:56end to allow the like trusted front end
  188. 7:59applications. So yeah.
  189. 8:01>> Okay. So suppose an API gets updated.
  190. 8:05Okay. Whatever you were working with
  191. 8:08earlier version so it got updated. So
  192. 8:10then how do you handle API versioning?
  193. 8:14So front end user are not impacted so
  194. 8:18that old request also should be keep on
  195. 8:21working along with the new request.
  196. 8:23>> Yeah. So when an API needs to be updated
  197. 8:26so we do not change the existing API
  198. 8:28directly because like it can break the
  199. 8:31front end that is uh already using it.
  200. 8:34So instead we create a new version of
  201. 8:36the API and we keep the old uh version
  202. 8:39running. So for example, let's say we
  203. 8:41have old API maybe API and then we say
  204. 8:45like forward/ maybe V1 then products and
  205. 8:49we can have the new API uh like API
  206. 8:52forward/ V2 and then products. So this
  207. 8:55way we can identify okay V_sub_1 is the
  208. 8:57older version and V2 is the newer
  209. 8:59version. So the existing front end
  210. 9:01continues uh using the V1 without any
  211. 9:04issues and the updated front end can
  212. 9:06start using the V2. So once all front
  213. 9:09end users are migrated to the new
  214. 9:11version then we like uh we mention the
  215. 9:14documentation for the deprecated this
  216. 9:17old API that was a v1 and when we are
  217. 9:22completely we we are not using this v1
  218. 9:25then we remove it later on. So this way
  219. 9:27like front end changes do not break and
  220. 9:30backward compar compatibility is also
  221. 9:32maintained. So yeah so that is how we
  222. 9:34are doing it.
  223. 9:35>> Okay. So how do you secure the API when
  224. 9:39react is calling the spring boot?
  225. 9:42>> Yeah, we secure APIs uh using the JWT
  226. 9:46based authentication. So that we are
  227. 9:48using currently. So React sends a token
  228. 9:50with like every request and spring boot
  229. 9:53like validates the token before allowing
  230. 9:55the access. So yeah.
  231. 9:57>> Okay. Can you explain bit more?
  232. 10:02>> Yeah. So whenever the user logs in from
  233. 10:05the react application then the
  234. 10:08credentials are sent to the spring boot
  235. 10:10back end. So after successful
  236. 10:12authentication the back end generates a
  237. 10:14JWT token and returns uh it to the
  238. 10:17react. So React stores this token
  239. 10:19securely and uh sends it with the uh
  240. 10:23every API request in the authorization
  241. 10:25header and spring boot intercepts each
  242. 10:28request and violates the token and uh
  243. 10:30checks user roles and permission. So if
  244. 10:33the tokens is valid then the request is
  245. 10:36processed and if it is missing expired
  246. 10:38or like invalid then the back end sends
  247. 10:41and authorize an error. Okay. [snorts]
  248. 10:44So we also use like https and like this
  249. 10:49uh we discussed like cos configuration
  250. 10:51and rule based access control to further
  251. 10:54secure the APIs. Yeah. So that is how we
  252. 10:56are using the JWT.
  253. 10:57>> Okay. So suppose in the react
  254. 11:00application the page load time is taking
  255. 11:04little bit more time than the actual
  256. 11:06one. So how do you improve it?
  257. 11:10>> Yeah. So we can improve the page load
  258. 11:12time by uh maybe uh lazy loading
  259. 11:16components. So that reduces the bundle
  260. 11:19size and minimizes the unnecessary API
  261. 11:21calls. So to improve the page uh load
  262. 11:26time in React application, we first
  263. 11:28reduce the initial bundle size by using
  264. 11:30the uh code splitting and lazy loading.
  265. 11:34So only in that case required components
  266. 11:37are loaded whenever needed. So we
  267. 11:39optimize API calls by uh fetching only
  268. 11:42necessary data and using the caching
  269. 11:46where it is possible. So we also use uh
  270. 11:49like u uh use memo and call back. So all
  271. 11:53these are there to avoid unnecessary
  272. 11:56rerenders. So that is like uh
  273. 11:57memorization. So that is also we can use
  274. 12:00and other improvements we can also do
  275. 12:03like uh maybe we can enable the browser
  276. 12:05caching also and we can avoid the like
  277. 12:08heavy computation on UI thread and all
  278. 12:10and also we can compress or optimize the
  279. 12:12images. So these are also the few hacks
  280. 12:16we can say so that we can use to uh make
  281. 12:19the UI load faster. So yeah so these are
  282. 12:23the things we can do. Yes.
  283. 12:26>> Okay. Can you tell me what happens
  284. 12:29behind the scene when you start a spring
  285. 12:32boot application?
  286. 12:34>> Yeah, when a spring boot application
  287. 12:37starts then it first runs the uh main
  288. 12:40method and then it launches the spring
  289. 12:42boot framework and spring boot then
  290. 12:45creates the application context. So that
  291. 12:47acts as the spring container we can say.
  292. 12:51And next it loads the environment
  293. 12:53properties from uh like we have files
  294. 12:56right applic.
  295. 13:00So from there it will read the
  296. 13:02environment uh properties and along with
  297. 13:04system and environment variables also.
  298. 13:06Uh after that it performs the class path
  299. 13:09scanning and to identify the components
  300. 13:13uh configuration and dependencies. So uh
  301. 13:16spring boot uh like we have like at the
  302. 13:18rate of uh spring boot start application
  303. 13:21right. So that is the reason why this
  304. 13:22all this uh configuration and
  305. 13:25dependencies or scannings are done. Then
  306. 13:27spring boot then applies auto
  307. 13:29configuration based on the dependencies
  308. 13:31available in the class path and it
  309. 13:33creates and initializes or all required
  310. 13:37beans and uh then it resolves their
  311. 13:39dependencies and manage their life
  312. 13:41cycle. So once the bean is ready then
  313. 13:45spring boot starts the embedded web
  314. 13:47server whatever the it is embedded with
  315. 13:49uh that is spring boot application and
  316. 13:52uh after that it executes uh command
  317. 13:55line runner or application runner logic
  318. 13:58and the application becomes like ready
  319. 14:01to handle incoming request. So this is
  320. 14:04what will happen behind the scen.
  321. 14:06>> Okay. Is it possible that spring auto
  322. 14:10wire we have annotation right that may
  323. 14:13sometime fail even when the bean exist.
  324. 14:17Is it possible?
  325. 14:18>> Yeah it is possible.
  326. 14:20>> Okay. Can you explain in what scenarios
  327. 14:24and more about it?
  328. 14:26>> Yeah. So uh like uh add that uh auto
  329. 14:29wired can fail due to multiple beams of
  330. 14:32the same type or missing component scan
  331. 14:35or like bean side uh bean life cycle and
  332. 14:38visibility issues. So even if a bean
  333. 14:41exist then order of to auto may fail in
  334. 14:44some situations like suppose we have
  335. 14:46multiple bean of same type. So can throw
  336. 14:50like no unique bean definition exception
  337. 14:52something like that. So so that can be
  338. 14:55fixed by add of qualifier or primary. So
  339. 14:58that concept comes in. So we have to use
  340. 15:01these annotations to tell uh spring that
  341. 15:04which one will be used uh like taken
  342. 15:06into consideration first. And also like
  343. 15:08bean is suppose not in the component
  344. 15:11scan path then also it can fail. So if
  345. 15:14the bean is defined outside of the
  346. 15:16package uh that spring scans then also
  347. 15:20it won't be detected. So automatically
  348. 15:22it bean will not be there into the uh
  349. 15:25memory. So it it will fail and uh then
  350. 15:30it does not work on static fields also
  351. 15:33because spring injects dependencies only
  352. 15:35into bean instances. So that is also
  353. 15:39might be the one reason also sometimes
  354. 15:42uh like the bean is requested before it
  355. 15:45is fully created or initialized then
  356. 15:48also it may fail sometimes.
  357. 15:50>> Okay. Okay. So can you tell me the
  358. 15:52scenario when bean got called before
  359. 15:55initialization?
  360. 15:57>> Uh I actually did not face it but it may
  361. 16:01happen. So uh like a bean can be called
  362. 16:06before full installation when it is uh
  363. 16:09accessed during a startup such as inside
  364. 16:12a constructor or a static block or early
  365. 16:16uh like life cycle phase. So one common
  366. 16:19scenario is using the uh like let's say
  367. 16:24bin A depends on bin B and again B is
  368. 16:27still the uh in the process of being
  369. 16:30created. So B and A again tries to use
  370. 16:34the bin B uh inside the constructor.
  371. 16:38Okay. So at this time B is not fully
  372. 16:41initialized. So calling the method using
  373. 16:44like it can give the null pointer
  374. 16:46exception. So uh that scenario may
  375. 16:49happen that I know but yeah I have not
  376. 16:51faced it in my uh uh project.
  377. 16:55>> Okay. So why we cannot use at the rate
  378. 16:58of autowired on a static fields.
  379. 17:02>> Yeah we cannot use it because a static
  380. 17:04fields belongs to class not to the bean
  381. 17:06instances. So spring injects uh
  382. 17:09dependencies only into bean instances.
  383. 17:12So it does not work on the static.
  384. 17:14>> Okay. Can you tell me the difference
  385. 17:16between application context and bean
  386. 17:19factory?
  387. 17:21>> Bean factory is the basic spring
  388. 17:24container responsible only for creating
  389. 17:28and managing beans. So it uses lazy
  390. 17:31initialization which means that the
  391. 17:33beans beans are created only when uh
  392. 17:36they are requested. So it provides core
  393. 17:39dependency injection features but very
  394. 17:42limited enterprise support. So
  395. 17:44application context in the other hand
  396. 17:46more advanced container we can say so
  397. 17:48that extends bean factory and provides
  398. 17:51the additional features required for the
  399. 17:54enterprise application. So it supports
  400. 17:56like in eager initialization. So that
  401. 17:58means that the most uh uh beans are
  402. 18:01created at startup itself. So yeah, so
  403. 18:04in the real world uh spring boot
  404. 18:06application application context is more
  405. 18:09preferred because it offers more
  406. 18:11functionality and better performance
  407. 18:13monitoring and that is easier to work
  408. 18:15with the uh like compared to the bin
  409. 18:16factory. Yeah. So this uh this context
  410. 18:19like this also supports like AOP and uh
  411. 18:23like uh some internalizations also
  412. 18:26supported. So those things are there but
  413. 18:28it is not there into the uh basic bean
  414. 18:31factory.
  415. 18:32>> Okay. So can you tell me one thing why
  416. 18:35doesn't spring roll back a transaction
  417. 18:38when a checked exception is thrown and
  418. 18:42how can this behavior be changed? You
  419. 18:44tell me that also. Yeah, by default
  420. 18:47spring transactional roll back uh
  421. 18:49transactions only for unchecked
  422. 18:52exceptions. So like for runtime and
  423. 18:55error. So the design follows the
  424. 18:58assumption that unchecked exceptions
  425. 19:00indicate programming or system failure
  426. 19:04that should uh invalidate and uh
  427. 19:07transactions.
  428. 19:08So checked exceptions on the other hand
  429. 19:11are treated as business or coverable
  430. 19:14exceptions. So spring assumes the uh
  431. 19:18application can handle them without
  432. 19:21requiring a roll back. So if a roll back
  433. 19:24is required for a checked exception then
  434. 19:27it must be explicitly uh configured
  435. 19:30using a roll back or uh uh roll back for
  436. 19:34class name attributes in like or address
  437. 19:37of transactional. So suppose uh like we
  438. 19:40have added transactional and uh we the
  439. 19:43bracket let's say we say roll back for
  440. 19:45exception.class. So that will force roll
  441. 19:48back for all exceptions. And if we say
  442. 19:51roll back for like any custom exception
  443. 19:54dot class so it will target that
  444. 19:56specific uh checked exceptions only. So
  445. 19:59that basically behaves uh behavior gives
  446. 20:02uh developers like uh good control over
  447. 20:05the uh transaction boundaries and avoid
  448. 20:08unnecessary road uh rollbacks and
  449. 20:10expected business scenarios.
  450. 20:13[snorts]
  451. 20:14>> Okay. Coming to microservices. Can you
  452. 20:16tell me in short what are microservices?
  453. 20:20>> Yeah, microservices is an architectural
  454. 20:23style where an application is divided
  455. 20:25into a small uh independent services and
  456. 20:29each service focuses on one business
  457. 20:31capability such as payment order or user
  458. 20:35management. So these services can be
  459. 20:37developed, deployed uh and scaled
  460. 20:41independently without uh affecting
  461. 20:43others. So yeah so that is what is a
  462. 20:46microservices
  463. 20:47>> and why do you think microservices are
  464. 20:50different from monolithic architecture?
  465. 20:52>> Yeah. So in a monolithic architecture
  466. 20:54the entire application is like one
  467. 20:57single unit with one uh deployment.
  468. 21:00Okay. And uh any small changes requires
  469. 21:04the redeploying the whole application.
  470. 21:06But in microservices each services is
  471. 21:08separate. So it will have its own uh
  472. 21:10database and uh uh all the uh
  473. 21:13dependencies also. So it will will be
  474. 21:15related to the data specific
  475. 21:16microservices and only. So the teams can
  476. 21:19update and deploy uh like uh these
  477. 21:22microservices independently. So the so
  478. 21:24that reduces the risk and downtime for
  479. 21:27this whole application. So that is what
  480. 21:30is the difference between uh these two.
  481. 21:32>> And how does microservices
  482. 21:36communicate with each other? Yeah,
  483. 21:38microservices usually communicate using
  484. 21:40REST APIs over HTTP for synchronous
  485. 21:44calls and for asynchronous communication
  486. 21:48they use message brokers like Kafka or
  487. 21:51Rabbit MQ. So yeah, so this basically
  488. 21:55helps services stay loosely coupled and
  489. 21:58it improves the system reliability.
  490. 22:02>> Okay. And what is service discovery?
  491. 22:05Yeah, service discovery basically allows
  492. 22:07microservices to find each other
  493. 22:10automatically at runtime and since
  494. 22:13services can scale up or grown then
  495. 22:17their IP addresses uh change uh
  496. 22:20frequently so we have tools like ureka
  497. 22:24so that helps uh register and locate
  498. 22:27services dynamically so that's what is
  499. 22:30the service discovery
  500. 22:31>> and how do you handle transactions
  501. 22:34across the microservices.
  502. 22:36>> Yeah, traditional databases uh
  503. 22:38transaction
  504. 22:40are not suitable for microservices. So
  505. 22:43state system is uses uh like saga
  506. 22:46pattern. So there each step has a uh
  507. 22:50like compensating action. So this ensure
  508. 22:53the data consistency across multiple
  509. 22:55services.
  510. 22:56>> Okay. Can you tell me what is the
  511. 22:59difference between double equal to and
  512. 23:02equals method in Java?
  513. 23:04>> Yeah, sure. So double equal to basically
  514. 23:06it compares the memory address like uh
  515. 23:10whether two references point to the same
  516. 23:13object and dot equals method compares
  517. 23:15the content or value inside that object.
  518. 23:18So like for example two different string
  519. 23:20objects with the same text. So that may
  520. 23:23return false like uh with whenever we
  521. 23:26are using double equal to but uh it will
  522. 23:29return true whenever we are using dot
  523. 23:30equals. So yeah so that's the
  524. 23:32difference.
  525. 23:34Okay. So let's say suppose you created a
  526. 23:38custom class called employee and it has
  527. 23:42fields like ID and name. Okay.
  528. 23:46And you again created two different
  529. 23:49employee objects with the same ID and
  530. 23:51name values. Right? So now when you
  531. 23:56compare them using dot equals so it is
  532. 23:59suppose returning false even though the
  533. 24:02data inside the both object is the same.
  534. 24:05So can you tell me why is this
  535. 24:06happening?
  536. 24:09>> Yeah. So since uh we are using only
  537. 24:12equals. So this happens because we did
  538. 24:15not override dot equals method uh in the
  539. 24:18custom class. So by default dot equals
  540. 24:20method from the object class is used. So
  541. 24:23the default uh implementation compares
  542. 24:26the memory address not the actual value
  543. 24:28inside the object. So even if the two
  544. 24:30objects have the same data so they are
  545. 24:33stored in different memory locations. So
  546. 24:36that's why the that equals uh returns
  547. 24:38false. So it will behave just like you
  548. 24:40can say like double equal to. So yeah so
  549. 24:44that's the reason why it is not equal.
  550. 24:46>> Okay. So what problem can this cause in
  551. 24:50case of h has set or hashmap?
  552. 24:52>> Yeah. So if we do not override equals
  553. 24:55and has code then it can create like
  554. 24:58issues uh in the h has set and hashmap.
  555. 25:01So uh het does not allow duplicate
  556. 25:05values but it uses uh high has code
  557. 25:07method first and then equals to check
  558. 25:10the duplicates. So if equals is not
  559. 25:12overridden in that case two objects with
  560. 25:15the same uh data will be like treated as
  561. 25:18a different objects and both will be
  562. 25:20stored in the same hset also. So
  563. 25:22duplicates will exist even though
  564. 25:24logically they are same. So uh that's
  565. 25:27what will happen in the hashet and in
  566. 25:28hashmap also like uh like hashmap uses h
  567. 25:32has code okay and it to find buckets and
  568. 25:35equals it it will use it uses to compare
  569. 25:38the keys. So if it is not overridden
  570. 25:41then uh two keys with the same data will
  571. 25:44be treated as different keys and also
  572. 25:47retrieval may fail. So we may not be
  573. 25:51able to get the value using the
  574. 25:52logically equal key. So that's what will
  575. 25:54happen. Yeah.
  576. 25:55>> Okay. And now suppose another scenario.
  577. 25:58So suppose you use a custom object as a
  578. 26:02key in the hashmap. Okay. And after
  579. 26:05inserting the object into the map, you
  580. 26:08modify one of its fields that is used in
  581. 26:12the hash code calculation.
  582. 26:14Okay. Now when you try to retrieve the
  583. 26:18value using the same object, so it
  584. 26:20returns null. So can you tell me why
  585. 26:23this happened? Uh yes. So when we insert
  586. 26:26a key into a hashmap, so Java uses the
  587. 26:30hash code method of that key to decide
  588. 26:33which bucket to store uh it in. Okay. So
  589. 26:36if the hash code changes after insertion
  590. 26:40then the object remains uh in the old
  591. 26:43bucket but when we try to retrieve it
  592. 26:46then hashmap calculates the new hash
  593. 26:48code and it searches in a different
  594. 26:50bucket also. Okay. So it cannot find the
  595. 26:54object. So even though the key is
  596. 26:55physically present inside the map, it
  597. 26:58becomes uh like uh you can say logically
  598. 27:01unreachable. So basically data cannot be
  599. 27:03retrieved and it will look like kind of
  600. 27:06data is lost and uh duplicate entries
  601. 27:09may get inserted. So ultimately it may
  602. 27:12cause the memory leaks because the old
  603. 27:14key is still uh I mean there in the map
  604. 27:16but it cannot accessed properly. It
  605. 27:18cannot be accessed properly. So we can
  606. 27:20say like a system behavior also becomes
  607. 27:22unpredictable in this point of time.
  608. 27:25Yeah.
  609. 27:26>> Okay. So can two unequal objects have
  610. 27:29the same hash code?
  611. 27:32>> Yeah it it can be there. So basically it
  612. 27:35is called hash collision. So we apply
  613. 27:39multiple methods to avoid this kind of
  614. 27:42collision and we take some measures
  615. 27:46to avoid that h collision.
  616. 27:49Okay. So what measures do you take to
  617. 27:52avoid that h collision?
  618. 27:54>> Uh actually we cannot completely avoid
  619. 27:56the h collision but we can reduce them
  620. 27:59by writing a good hash code method and
  621. 28:02using the proper key design. So uh that
  622. 28:06way we can do that but yeah we cannot
  623. 28:09still guarantee that it the collision
  624. 28:11will never occur.
  625. 28:14>> Okay fine. So can you tell me the
  626. 28:17difference between arraylist and link
  627. 28:19list?
  628. 28:21>> Yeah sure. So array list basically uses
  629. 28:23a dynamic array internally. So it is
  630. 28:27fast for random access. So we can get by
  631. 28:30index in case of array list and link
  632. 28:33list uses a doubly link list internally.
  633. 28:35So uh it is faster for insertion and
  634. 28:38deletion in the middle but link list
  635. 28:41uses more memory compared to array list.
  636. 28:44So yeah, so that's the difference
  637. 28:46between array list and link list.
  638. 28:49>> Okay. And if linked list is faster for
  639. 28:52insertion, then why is array list is
  640. 28:55more commonly used?
  641. 28:57>> Because in real application we do more
  642. 29:00like read operations like we do mostly
  643. 29:03get by index thing and all we do that.
  644. 29:06So we do insertion in the middle we do
  645. 29:08very like less. It is not frequently
  646. 29:11used but wherever we have the scenario
  647. 29:14like we have to do insertion in the
  648. 29:16middle and all in that case we can go
  649. 29:18for that link list otherwise we use the
  650. 29:20array list. So array list basically
  651. 29:22provides O of one random access while
  652. 29:25linked list takes O of N times to access
  653. 29:28the by index. So uh that's why the
  654. 29:32there's a difference between the speed
  655. 29:34and that's why we use mostly uh like
  656. 29:36array list but it's all depends on the
  657. 29:38scenario
  658. 29:40and in real applications like uh uh
  659. 29:43scenario of get by index comes more
  660. 29:47compared to the insertion in the middle.
  661. 29:49>> Okay. So if you need to frequently
  662. 29:51remove elements from the beginning of
  663. 29:54the list so which is better?
  664. 29:58uh if we have to remove from the
  665. 30:00beginning link list we should use
  666. 30:02because array list will sift like all
  667. 30:04elements right so that will be costly
  668. 30:07but it won't be the case in case of link
  669. 30:09list so linked to be the better bit here
  670. 30:12>> okay so what happens when multiple
  671. 30:15threads increment a shared counter
  672. 30:19>> uh if multiple thread uh increment a
  673. 30:22shared counter then uh race conditions
  674. 30:25uh occur so which can lead to incorrect
  675. 30:28or inconsistent result.
  676. 30:31>> Okay. Can you explain bit more?
  677. 30:35>> Yeah. So when multiple threads try to
  678. 30:37increment the same shared counter at the
  679. 30:40same time then problems can occur
  680. 30:42because the uh increment operation is
  681. 30:44not atomic. So incrementing like counter
  682. 30:48plus suppose if you're using so that is
  683. 30:49actually uh a three-step process we can
  684. 30:52say. So first of all it reads the
  685. 30:54current value then add one to it and
  686. 30:56then write the new value back. Okay. So
  687. 30:59if two threads read the same value at
  688. 31:02the same time then both may read for
  689. 31:04example five and both increment it to
  690. 31:07six and both will uh like write back six
  691. 31:11again. So instead of becoming seven the
  692. 31:14value becomes six six. So this is called
  693. 31:17a race condition because the threads can
  694. 31:20uh and threads are racing to update the
  695. 31:23same variable basically. So that is why
  696. 31:26it is called race condition. So it will
  697. 31:28ultimately lead to data consist uh
  698. 31:31consistency and uh unpredictable system
  699. 31:35behavior and all. So yeah.
  700. 31:39>> Okay. And how can you fix it?
  701. 31:42>> Yeah. To fix this we can use
  702. 31:43synchronized keyword and atomic integer
  703. 31:46also we can use. So yeah so these we can
  704. 31:49do.
  705. 31:50>> So why doesn't volatile fix it this
  706. 31:52problem?
  707. 31:53>> Yeah volatile basically insures the
  708. 31:55visibility of changes across threads but
  709. 31:58it does not makes operations atomic. So
  710. 32:02when we mark a variable as volatile then
  711. 32:04it guarantees that any change made by uh
  712. 32:08one thread is uh immediately visible to
  713. 32:10another thread. So the value is always
  714. 32:13uh read from main memory not from the
  715. 32:16thread cach but volatile does not make
  716. 32:19uh uh like compound uh uh operations
  717. 32:23atomic. So uh even if the like variable
  718. 32:27is volatile so two threads can read the
  719. 32:30same value at the same time it can
  720. 32:31increment it also and it can write back
  721. 32:34the same result. So the final value can
  722. 32:36still be incorrect. So yeah
  723. 32:38>> suppose you deployed your spring boot
  724. 32:41application multiple times on a server.
  725. 32:44So let's say for example on Tomcat. So
  726. 32:46after every deployment you suppose
  727. 32:49notice the heap memory
  728. 32:51keeps increasing and it never fully
  729. 32:54comes back down. So even after
  730. 32:57restarting the application inside the
  731. 32:59same server memory uses keep on growing.
  732. 33:02So can you tell me what might be the
  733. 33:04reason and why it is growing? Yeah. So
  734. 33:07this usually happens because some
  735. 33:08objects from the previous uh deployment
  736. 33:10are not getting uh garbage collected.
  737. 33:13That might be the reason. And in Java uh
  738. 33:17application servers uh every deployment
  739. 33:20creates a new class loader. So if
  740. 33:22something from the old deployment is
  741. 33:24still uh being referenced then the old
  742. 33:27class loader cannot be uh garbage
  743. 33:29collected. Okay. So this is basically
  744. 33:32called a class uh loader leak. So uh
  745. 33:36there might be multiple reasons again.
  746. 33:38So for example static variables if we
  747. 33:42store large objects into static fields
  748. 33:45uh then so these basically stay in the
  749. 33:47memory as long as the class is loaded.
  750. 33:49So if not cleared properly they prevent
  751. 33:51garbage collection and also like there
  752. 33:55might be reason like we if we use
  753. 33:57suppose thread local and and we forget
  754. 34:00to remove values like remove method so
  755. 34:03it may hold references to the old object
  756. 34:06that might be the another reason and
  757. 34:08also the caching so in memory caches
  758. 34:11like custom maps uh eh cache radius and
  759. 34:14all so if it is not clear during then
  760. 34:19also it can uh uh like retain the old
  761. 34:22references. So these are the few uh like
  762. 34:26uh reasons I am able to think of and
  763. 34:28also like if suppose uh in case of
  764. 34:31database connection so if connection
  765. 34:33pools are not closed properly then also
  766. 34:36they may cause the memory and so these
  767. 34:39might be the reason. Yeah.
  768. 34:40>> So you have experience on git right? So
  769. 34:44can you tell me what is the difference
  770. 34:45between git and github? Git is basically
  771. 34:49a distributed version control system
  772. 34:52used to track the code changes and
  773. 34:55GitHub is a cloud-based platform where
  774. 34:58git repositories are hosted and managed.
  775. 35:01So yeah.
  776. 35:02>> Okay. So can you tell me what are the g
  777. 35:05commands you are aware of?
  778. 35:06>> Yeah. So there are many commands like uh
  779. 35:09we have uh get clone first of all. So uh
  780. 35:13whenever we have to clone for from the
  781. 35:15remote repository so we use get clone
  782. 35:18and then uh uh suppose we make any
  783. 35:22changes uh to our uh downloaded
  784. 35:25repository then we can say get status.
  785. 35:27So it will check it will show whatever
  786. 35:30changes we have done and uh then we have
  787. 35:33get uh add. So if suppose if you want to
  788. 35:36push the file uh like add and push to
  789. 35:39repository then we can add that and give
  790. 35:42that file name whatever we want to uh we
  791. 35:45are planning to push and then we say get
  792. 35:48commit minus m so and we can give the
  793. 35:51message. So appropriate message we can
  794. 35:53give why we are pushing what changes we
  795. 35:55have done and all. And then we have git
  796. 35:58push. So that we use for for the push.
  797. 36:01And then uh uh we also have git log. So
  798. 36:04that we use to view uh commit history.
  799. 36:07Apart from that we have g branch. So it
  800. 36:10will list out all the branches or if we
  801. 36:13want to check out some specific branch
  802. 36:15so we can just say get check out uh that
  803. 36:17branch name. So it will switch to that
  804. 36:19specific branch. And uh apart from that
  805. 36:23we have get status. So suppose uh we are
  806. 36:27using uh any changes we have done to uh
  807. 36:32some specific branch and uh we don't
  808. 36:35want to lose that and we have to make
  809. 36:36some changes to different branch. So
  810. 36:38till we temporarily save that uh uh
  811. 36:41uncommitted changes and uh so that we
  812. 36:45stash that and later once we come back
  813. 36:47to that branch we can again uh uh revert
  814. 36:50it and uh we can uh push that whatever
  815. 36:54changes we want. So yeah, so these are
  816. 36:56the mostly we use the uh these commands.
  817. 36:59Yeah.
  818. 37:00>> Okay. Do you know git rebase?
  819. 37:02>> Yeah. G rebase is used to move or uh
  820. 37:07replay your branch commit on top of
  821. 37:10another branch to maintain a clean and
  822. 37:12uh linear commit history. So suppose
  823. 37:16when we use git rebase. So get takes the
  824. 37:20uh commits from our current branch and
  825. 37:22applies them again on top of the another
  826. 37:24branch.
  827. 37:25>> Okay. So can you tell me what is CI/CD?
  828. 37:28>> CICD. So yeah, so CI/CD basically stands
  829. 37:30for continuous integration and
  830. 37:32continuous uh deployment. So it uh
  831. 37:35automates the process of building,
  832. 37:37testing and deploying applications. So
  833. 37:40uh continuous integration means
  834. 37:42developers regularly push their code to
  835. 37:45a shared repository like GitHub and
  836. 37:48whenever code is pushed so the project
  837. 37:50is automatically built and unit test are
  838. 37:53executed and code quality checks and all
  839. 37:56are performed. So if something fails
  840. 37:59then the team is uh like immediately
  841. 38:01notified so that we can fix it. So
  842. 38:03basically this helps to catch uh like
  843. 38:05bugs early and avoids uh integration
  844. 38:09issues later and the continuous
  845. 38:11deployment basically uh after the build
  846. 38:14and test are successful. So the
  847. 38:17application is automatically deployed to
  848. 38:19uh staging or production. So no manual
  849. 38:23uh deployment is needed in full
  850. 38:26continuous deployment. So in continuous
  851. 38:28delivery deployment may require manual
  852. 38:31approval. So, so basically this ensures
  853. 38:35the faster and reliable release. So,
  854. 38:37yeah. So, that is what CI/CD pipeline we
  855. 38:40build. Yeah. Okay. And what is the
  856. 38:42difference between docker image and
  857. 38:44container?
  858. 38:45>> Yeah. So, image is a blueprint we can
  859. 38:48say. So, uh and container is a running
  860. 38:52instance of that image. So, docker image
  861. 38:56is read only template and docker
  862. 38:58container is a running version of that
  863. 39:00image. So for example we have a java
  864. 39:03spring boot app package and all. So that
  865. 39:05is we can say image and running the
  866. 39:07spring boot application like uh that we
  867. 39:10do on container.
  868. 39:12So yeah
  869. 39:13>> and do you know what is blue green
  870. 39:15deployment are you aware of it?
  871. 39:18>> Yeah. So it is a deployment strategy
  872. 39:21with uh two environments. So blue means
  873. 39:23current and green means new. So uh blue
  874. 39:27like live production environment is
  875. 39:29there then we say blue and green like
  876. 39:31new version. So once testing is done on
  877. 39:34green then traffic is switched off uh
  878. 39:36like switched from the blue to green. So
  879. 39:39if something fails we switch back
  880. 39:41easily. So
  881. 39:43basically this reduces the down time. So
  882. 39:46yeah, so that's what uh blueg deployment

About this transcript

This page contains the full transcript of πŸ”” Java / Full Stack Developer | 2–8 Years Experience | Spring Boot | Microservices | ReactJS | Git by Insights Instructor, generated from the public captions YouTube serves with the video. The transcript has 6,084 words across 882 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator β€” no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.